nerdexam
LPI

305-300 · Question #4

If docker stack is to be used to run a Docker Compose file on a Docker Swarm, how are the images referenced in the Docker Compose configuration made available on the Swarm nodes?

The correct answer is C. docker stack instructs the Swarm nodes to pull the images from a registry, although it does not. Docker stack is a command that allows users to deploy and manage a stack of services on a Docker Swarm cluster. A stack is a group of interrelated services that share dependencies and can be orchestrated and scaled together. A stack is typically defined by a Compose file, which…

303.4 Operations Security

Question

If docker stack is to be used to run a Docker Compose file on a Docker Swarm, how are the images referenced in the Docker Compose configuration made available on the Swarm nodes?

Options

  • Adocker stack builds the images locally and copies them to only those Swarm nodes which run the
  • Bdocker stack passes the images to the Swarm master which distributes the images to all other
  • Cdocker stack instructs the Swarm nodes to pull the images from a registry, although it does not
  • Ddocker stack transfers the image from its local Docker cache to each Swarm node.
  • Edocker stack triggers the build process for the images on all nodes of the Swarm.

How the community answered

(30 responses)
  • A
    13% (4)
  • B
    3% (1)
  • C
    70% (21)
  • D
    3% (1)
  • E
    10% (3)

Explanation

Docker stack is a command that allows users to deploy and manage a stack of services on a Docker Swarm cluster. A stack is a group of interrelated services that share dependencies and can be orchestrated and scaled together. A stack is typically defined by a Compose file, which is a YAML file that describes the services, networks, volumes, and other resources of the stack. To use docker stack to run a Compose file on a Swarm, the user must first create and initialize a Swarm cluster, which is a group of machines (nodes) that are running the Docker Engine and are joined into a single entity. The Swarm cluster has one or more managers, which are responsible for maintaining the cluster state and orchestrating the services, and one or more workers, which are the nodes that run the services. When the user runs docker stack deploy with a Compose file, the command parses the file and creates the services as specified. However, docker stack does not build or upload the images images from a registry, which can be the public Docker Hub or a private registry. The user must ensure that the images are available in the registry before deploying the stack, otherwise the deployment will fail. The user can use docker build and docker push commands to create and upload the images to the registry, or use an automated build service such as Docker Hub or GitHub Actions. The user must also make sure that the image names and tags in the Compose file match the ones in the registry, and that the Swarm nodes have access to the registry if it is private. By pulling the images from a registry, docker stack ensures that the Swarm nodes have the same and latest version of the images, and that the images are distributed across the cluster in an efficient way.

Topics

#Docker Swarm#docker stack#image registry#container distribution

Community Discussion

No community discussion yet for this question.

Full 305-300 Practice