- Set up Docker's apt repository.
# Add Docker's official GPG key:
sudo apt-get update
sudo apt-get install ca-certificates curl gnupg
sudo install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
sudo chmod a+r /etc/apt/keyrings/docker.gpg
# Add the repository to Apt sources:
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
$(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update- Install the Docker packages.
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin- Fix docker permission
sudo usermod -aG docker $USERYou need to reboot to apply the change
- Verify that the Docker Engine installation is successful by running the hello-world image.
sudo docker run hello-worldThis command downloads a test image and runs it in a container. When the container runs, it prints a confirmation message and exits.
- Verify that Docker Compose is installed correctly by checking the version.
docker compose version
# Expected output:
Docker Compose version vN.N.N
# Where vN.N.N is placeholder text standing in for the latest version.Instructions taken from docker official install guide and compose plugin install guide.
To check your current Docker Engine version use the command : docker version
sudo apt remove docker.io docker-compose docker-doc containerd runcsudo apt install ca-certificates curlsudo install -m 0755 -d /etc/apt/keyrings
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyrings/docker.ascecho "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] \
https://download.docker.com/linux/ubuntu $(. /etc/os-release && echo $VERSION_CODENAME) stable" | \
sudo tee /etc/apt/sources.list.d/docker.list > /dev/nullsudo apt update
sudo apt install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-pluginNow check again the version which should be the latest version.
First you can scan how much disk space docker used with the following command :
docker system dfIf you need to make some space on your machine because your docker related files take too much space, you can run the following commands to clean your system :
# Remove all unused containers, networks, images (both dangling and unreferenced)
# https://docs.docker.com/engine/reference/commandline/system_prune/
docker system prune -a
# Remove all unused local volumes. Unused local volumes are those which are not referenced by any containers. By default, it only removes anonymous volumes.
# https://docs.docker.com/engine/reference/commandline/volume_prune/
docker volumes prune -aLike the application code, the Dockerfile and the image it builds must be audited. Three tools are wired in the Makefile for that purpose:
- hadolint : lints the
Dockerfilesyntax and best practices. - dockle : checks the built image against container security best practices (setuid binaries, root user, secrets, ...).
- osv-scanner : lists the known vulnerabilities (CVE) of the system and PHP packages installed in the image.
All tools are run through their own docker image so there are no install setup requirement.
# Run the three scans at once
make docker-scan
# Or run them individually
make docker-lint
make docker-scan-dockle
make docker-scan-osv
# Same OSV scan served as an HTML report on http://localhost:8000/
make docker-scan-osv-htmlThe scans run on the image built by make build, so rebuild it before scanning to audit your latest changes.
Accepted dockle exceptions are listed and justified in the .dockleignore file at the project root. Any new finding
must be fixed rather than appended to that file.