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)
Please note that this page uses examples that execute the Ubuntu apt package manager. If you're on macOS, you'll want to use brew instead. If you're on another Linux distro, package names might be different and you might have a different package manager other than apt.
sudo apt remove docker docker-engine docker.iosudo apt install apt-transport-https ca-certificates curl software-properties-common gnupgcurl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -sudo apt-key fingerprint 0EBFCD88sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"sudo apt update
sudo apt install docker-cesudo 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
exposekeyword will "expose" that Docker container's port to the host server— as well as to other containers active on the server. - The
portskeyword 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.

