containers

containers are like VMs but more efficient

containers share a kernel so they start much faster than VMs

  • docker container run

     run is the command used to start new containers. In its simplest form, it accepts an image and a command as arguments. The image is used to create the container and the command is the application you want the container to run. This example will start an Ubuntu container in the foreground, and tell it to run the Bash shell: docker container run -it ubuntu /bin/bash

  • Ctrl-PQ

    will detach your shell from the terminal of a container and leave the container running (UP) in the background

  • docker container ls

    lists all containers in the running (UP) state. If you add the -a flag you will also see containers in the stopped (Exited) state. • docker container exec lets you run a new process inside of a running container. It’s useful for attaching the shell of your Docker host to a terminal inside of a running container. This command will start a new Bash shell inside of a running container and connect to it: docker container exec -it <container-name or container-id> bash

  • docker container stop

    will stop a running container and put it in the Exited (0) state. It does this by issuing a SIGTERM to the process with PID 1 inside of thecontainer.Iftheprocesshasnotcleanedupandstoppedwithin10seconds, a SIGKILL will be issued to forcibly stop the container. docker container stop accepts container IDs and container names as arguments

  • docker container start

    will restart a stopped (Exited) container. You can give docker container start the name or ID of a container

  • docker container rm

    will delete a stopped container. You can specify containers by name or ID

  • docker container inspect

    will show you detailed configuration and run time information about a container. It accepts container names and container IDs as its main argument