We first want to make sure that docker is installed.

Installing docker & compose

  1. Install docker: sudo apt update && sudo apt install -y docker.io
  2. install docker compose, this is also explained below for Ubuntu users:

Docker Compose for Ubuntu:

1.Set up Docker’s apt repository.

# Add Docker's official GPG key:
sudo apt-get update
sudo apt-get install ca-certificates curl
sudo 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.asc

# Add the repository to Apt sources:
echo \
  "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \
  $(. /etc/os-release && echo "${UBUNTU_CODENAME:-$VERSION_CODENAME}") stable" | \
  sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update

2.Install the Docker packages.

sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin

3.Update the package index, and install the latest version of Docker Compose:

sudo apt-get update
sudo apt-get install docker-compose-plugin

4.Verify that Docker Compose is installed correctly by checking the version.

docker compose version

Verify installation

Check now with the following command whether Docker is running automatically:
sudo systemctl status docker

If it shows Active: failed, then run this command to start Docker:
sudo systemctl start docker

Start your container

you do need a docker-compose.yaml file.

Then from that directory, run the following command to start it:

sudo docker compose up -d

Stop the container

To stop it, run this command:

sudo docker compose stop

Building Docker

If you are using a Docker Compose setup uses a custom-configured Apache container. When running docker compose up -d, the latest version of the Dockerfile will not be built automatically.
To force a rebuild, you can use the following command:

docker compose up -d --no-deps --build

Als je het wilt restarten kun je stop en Building combineren:

sudo docker compose stop && sudo docker compose up -d --no-deps --build