Written by The Jahia Team
   Estimated reading time:

A Docker image is a static model containing a preinstalled application. When running this image, a container is created. An image can be used to start as many containers as needed. The following diagram shows the life cycle of a Docker container and associated commands.

image1.jpg

There are two ways of getting a Docker image:

  • Retrieve a Docker image from a registry (often Docker Hub).
  • Build it from a Dockerfile. All standard Jahia and jCustomer Docker images are available as public Docker Hub images.

Docker command cheat sheet

To list all running containers, execute this Docker command:

docker ps

image2.png

To list all the containers on your machine, including the ones that are stopped or exited:

docker ps -a

Note: For more options, refer to the Docker documentation.

To run a container in detached mode:

docker run -p 8080:8080 -d jahia/jahia-dev:{dx version}

The command executes the container and returns the container’s UUID. You may need the command if you have not named your container.

In detached mode, you can still display the standard output logs of the container in a console by executing this Docker command:

docker logs -f {container_id}

To stop a container:

docker stop {container_id}

As an alternative, the CTRL+C shortcut (COMMAND+C on macOS) stops the container started in attached mode.

To start a container:

docker start {container_id}

To delete a container:

docker rm {container_id}

To remove and start a new container with a given name, add --rm as a parameter to the run command:

docker run -p 8080:8080 --rm --name {container name} jahia/jahia-dev:{dx version}