docker-compose.yml¶
This is a YAML file defining services, networks, and volumes for multi-container
Docker applications. In other words, all the parameters you have used with
docker run
you could specify in a docker-compose.yml
file. Then, with a
single command, create and start all the services with your configurations.
In this example, we will launch just one image, but keep in mind that a
docker-compose.yml
file could specify more than one image at the same time.
Tip
For more information, see the Compose File Version 3 Reference
Move the default docker-compose.yml
from shellhttpd.disabled
to your folder:
Read the docker-compose.yml
file:
docker-compose.yml:
Most of the parameters were already used in the previous commands. The only thing you need to change is the image parameter.
In the next tutorial, you will build and deploy the image with
FoundriesFactory and there the image with hub.foundries.io
will be necessary.
For now, because you are still developing locally, you need to edit the image parameter to use the image you have built in the previous steps.
Change the image parameter to the name and tag we built locally shellhttpd:1.0
:
docker-compose.yml:
Notice that the MSG variable is configured to use Hello world
as default.
To run your docker-compose
application, execute the docker-compose up --detach
command.
- Where:
--detach
or-d
- Run containers in the background.
To verify the running containers:
Example Output:
Test the container with curl
:
Example Output: