Skip to content

Containers

Dmytro Somliev edited this page Apr 1, 2022 · 3 revisions

Containers

  • docker run image_id - create a NEW container based on image. Container running in a foreground (Attached mode). No exit after command execution. Instead of image_id we can specify image_name:tag.

    • -d - flag to run container in a Detached mode.
    • -it - gives ability to interact with soft inside container (node shell e.g.). i means interactive mode and t means terminal related. This flag is ALWAYS should be present when you try to run React App inside of Container.
    • -p local_port_number:container_port_number - flag that publish to local port number from a container port number.
    • --rm - will delete running container when it stops.
    • --name your_container_name - give a running container a name.
  • docker ps - list of all running containers

  • docker ps -a :

    • ps stands for processes.
    • -a mean show all.
  • docker start container_name - restart the existed container. Container running in a background (Detached mode). Exit after command execution.

    • -a - flag to run container in a Attached mode.
  • docker stop container_name - to stop the container run.

  • docker attach container_name||container_id - Makes Attached mode on for a container that was started in a Detached mode.

  • docker logs container-name - fetches the logs that were printed by container.

  • docker rm container_name - remove container. Works only for stopped containers. You can remove a couple containers at once.

    • docker container prune - remove all stopped containers at once.
  • docker exec container_name your_command - allow to run additional commands inside of the container, which are not included into Dockerfile.

Clone this wiki locally