Let's say you have the following docker-compose.yml file which contains two services, foo and bar.
version: "3.7"
services:
foo:
image: foo:latest
bar:
image: bar:latest
The docker stack deploy command can be used to deploy or redeploy (update) the stack.
docker stack deploy --compose-file docker-compose.yml stack001
A Docker image contains the code used to create a Docker container, such as creating a Nginx web server, or a mySQL server, or a home grown app, and the list goes on. In this way, an image is like a template used to create a container. An image is kind of like a virtual machine, but much more light weight, using significantly less storage a memory (containers are usually megabytes in size).
There are various ways to pull down an image:
If this is the first deploy of the stack, and the deploy is successful, something like this should be returned.
Creating network stack001_default
Creating service stack001_foo
Creating service stack001_bar
The docker network ls command can be used to confirm that the stack001_default network was created.
NETWORK ID NAME DRIVER SCOPE
r0zassvat4e5 stack001_default overlay swarm
The docker stack ls command can be used to confirm that the stack was created.
NAME SERVICES ORCHESTRATOR
stack001 2 Swarm
The docker stack services command can be used to confirm that the foo and bar services were created.
ID NAME MODE REPLICAS IMAGE
ivq9h5yxl1om stack001_foo replicated 1/1 registry.example.com/stack001_foo:latest
kod8l0fc9alv stack001_bar replicated 1/1 registry.example.com/stack001_bar:latest