Docker Compose YAML¶
docker-compose.yml
defines the services, networks, and volumes for multi-container Docker apps.
All the parameters you have used with docker run
you can specify in docker-compose.yml
.
Then, with a single command, create and start all the services with your configurations.
In the following example, we will launch a single image, but keep in mind that a docker-compose.yml
can specify multiple images.
Tip
For more information, see the Compose File Version 3 Reference
Move the default docker-compose.yml
from shellhttpd.disabled
to your folder:
Review the docker-compose.yml
file:
docker-compose.yml:
Most of the parameters were already used in the previous commands. The only thing to change is the image parameter.
In the next tutorial, you will build and deploy with FoundriesFactory®, where hub.foundries.io
will be necessary.
As you are still developing locally, edit the image parameter to use the image and tag from the previous steps, 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.
Using --detach
or -d
runs containers in the background.
To verify the running containers:
Example Output:
Test the container with curl
:
Example Output: