Jump to contentJump to page navigation: previous page [access key p]/next page [access key n]
Applies to SUSE Linux Enterprise Server 12 SP4

7 Working with Containers Edit source

After you have created your images, you can start your containers based on that image. You can run an instance of the image by using the docker run command. The Docker Open Source Engine then creates and starts the container. The command docker run takes several arguments:

  • A container name - it is recommended to name your container.

  • Specify a user to use in your container.

  • Define a mount point.

  • Specify a particular host name, etc.

The container typically exits if its main process finishes. For example, if your container starts a particular application, as soon as you quit the application, the container exits. You can start the container again by running:

docker start -ai <container name>

You may need to remove unused containers, you can achieve this by using:

docker rm <container name>

7.1 Linking Containers Edit source

Docker Open Source Engine enables you to link containers together which allows for communication between containers on the same host server. If you use the standard networking model, you can link containers by using the --link option when running containers:

First create a container to link to:

docker run -d --name sles sles12sp4 /bin/bash

Then create a container that will link to the sles container:

docker run --link sles:sles sles12sp4 /bin/bash

The container that links to sles has defined environment variables that enable connecting to the linked container.

Print this page