Setting and running applications using Docker.
- Article for the below steps: https://docs.docker.com/engine/install/ubuntu/
- Check if you have the OS requirements (Bionic) by running
cat /etc/*release*
on the terminal. - Uninstall old versions by running
sudo apt-get remove docker docker-engine docker.io containerd runc
. - Set up the repository.Easier way to install docker is to go down to the bottom Install using the convenience script.
curl -fsSL https://get.docker.com -o get-docker.sh
sudo sh get-docker.sh
- Check docker version by running
sudo docker version
command.
- (optional) Run a simple container to ensure everything is running as expected:
sudo docker run docker/whalesay cowsay Hello-World
found in the docker hubhttps://hub.docker.com/r/docker/whalesay
.
- RUN
sudo pip install docker-compose
NB: In computer networking, port forwarding or port mapping is an application of network address translation (NAT) that redirects a communication request from one address and port number combination to another while the packets are traversing a network gateway, such as a router or firewall.
$ docker run --name mynginx -p 80:80 -d nginx
mynginx
is the name of the created container based on the NGINX image.- the
-d
option specifies that the container runs in detached mode: the container continues to run until stopped but does not respond to commands run on the command line. - the
-p
option tells Docker to map the ports exposed in the container by the NGINX image (port80
) to the specified port on the Docker host. The first parameter specifies the port in the Docker host, the second parameter is mapped to the port exposed in the container.
Guide to creating Docker Images and Docker-Compose:
- "Docker-composing" a Python 3 Flask App Line-by-Line
- How To Serve Flask Applications with uWSGI and Nginx on Ubuntu 18.04
- Dockerizing a Python 3 Flask App Line-by-Line
1. How To Set Up Flask with MongoDB and Docker