- Update your existing list of packages and install the perquisites:
sudo apt update && sudo apt install apt-transport-https ca-certificates curl gnupg2 software-properties-common
- Add the GPG key for the official Docker repository to your system:
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
- Add the Docker repository to APT sources:
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/debian $(lsb_release -cs) stable"
- Update the package database with the Docker packages from the newly added repo:
sudo apt update
- Install Docker:
sudo apt install docker-ce
sudo systemctl status docker - Add your user to the docker group. Log out and back in to apply the changes:
sudo usermod -aG docker ${USER}
- Check the latest Docker Compose version here (currently 1.27.4) and run the following command accordingly:
sudo curl -L https://github.com/docker/compose/releases/download/1.27.4/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose - Verify the installation was successful:
docker-compose --version
- Try creating your first container with Docker Compose:
mkdir hello-world && cd hello-world && nano docker-compose.yml
Copy and paste the following into the file:
test:
image: hello-world - Create the container (if there’s no local image named
hello-world
, it will pull the image from the Docker Hub public repository), attach, and run the program:
docker-compose up -d
- Show all existing Docker containers:
docker ps -a
- Stop and remove all Docker containers:
docker stop $(docker ps -a -q)
docker rm $(docker ps -a -q)