Docker  is a great tool for automating the deployment of Linux applications inside software containers, but to take full advantage of its potential each component of an application should run in its own individual container.

Step 1 — Installing Docker Compose

sudo curl -L`uname -s`-`uname -m` -o /usr/local/bin/docker-compose

sudo chmod +x /usr/local/bin/docker-compose

docker-compose --version

Step 2 — Running a Container with Docker Compose

First, we’ll create a directory for the YAML file and move into it:

mkdir hello-world
cd hello-world

Then, we’ll create the YAML file:

nano docker-compose.yml
 image: hello-world
docker images
docker-compose up

OutputPulling my-test (hello-world:latest)...
latest: Pulling from library/hello-world
c04b14da8d14: Downloading [==================================================>] c04b14da8d14: Extracting [==================================================>]  c04b14da8d14: Extracting [==================================================>]  c04b14da8d14: Pull complete
Digest: sha256:0256e8a36e2070f7bf2d0b0763dbabdd67798512411de4cdcf9431a1feb60fd9
Status: Downloaded newer image for hello-world:latest
. . .

docker ps -a

Step 3 — Removing the Image (Optional)

docker ps -a
docker rm 06069fd52a13
docker rmi hello-world
Categories: How-to

fr_FRFrançais en_USEnglish