Installation
Though I work hard to provide the most up-to-date information in this knowledge base, I don't always have the time to manage everything myself. To ensure you're following the latest installation instructions for your platform, I recommend visiting the official documentation .
Install Docker Community Edition (CE)
Examples are using the Ubuntu APT package manager. Mileage may vary.
sudo apt remove docker docker-engine docker.io
sudo apt install apt-transport-https ca-certificates curl software-properties-common gnupg
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo apt-key fingerprint 0EBFCD88
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
sudo apt update
sudo apt install docker-ce
sudo usermod -aG docker $USER
Install Docker Compose
sudo apt update
sudo apt install docker-compose-plugin
Tips
docker-compose down -v --rmi all --remove-orphans
Expose vs Ports
In a docker-compose.yml
file, you have the option to use either:
...
expose:
- 5432
...
# and/or
...
ports:
- 5432:5432
...
These two options look benignly similar, but they are critically different:
- The
expose
keyword will "expose" that Docker container's port to the host server— as well as to other containers active on the server. - The
ports
keyword will map the container's port to the host's port.
The significance of this is that a port map of 443:443
on a containerized Nginx or Apache will allow external traffic (i.e., the public Internet) to interact directly with the Docker container's Web server. However, if using expose
for 443
instead, that container won't be public.
This is an important distinction for things like databases or mem-cache services (Redis) that you might not want exposed to the public Web. In those instances, expose
will still allow other containers to interface on the same host without allowing external inspection.