docker start

Command Name: 

docker start

Description:

Starts one or more stopped containers.

Steps:

  • Pull the tomcat image from hub.docker.com
  • Run the tomcat images
  • Stop the tomcat container
  • Start the tomcat container

 

Syntax:

easywhatis$ docker start --help

Usage: docker start [OPTIONS] CONTAINER [CONTAINER...]

Start one or more stopped containers

Options:
  -a, --attach               Attach STDOUT/STDERR and forward signals
      --detach-keys string   Override the key sequence for detaching a container
  -i, --interactive          Attach container's STDIN
easywhatis$

Example:

Steps:

  • Pull the tomcat image from hub.docker.com
  • Run the tomcat images
  • Stop the tomcat container
  • Start the tomcat container
easywhatis$ docker pull tomcat
Using default tag: latest
latest: Pulling from library/tomcat
50e431f79093: Pull complete
dd8c6d374ea5: Pull complete
c85513200d84: Pull complete
55769680e827: Pull complete
e27ce2095ec2: Pull complete
5943eea6cb7c: Pull complete
3ed8ceae72a6: Pull complete
91d1e510d72b: Pull complete
415cc4506e71: Pull complete

a79d88064227: Pull complete
Digest: sha256:b707d3b8b4f40951ca2f387c24ab9f78800c69c90740f0cca937a1b95204b3a4
Status: Downloaded newer image for tomcat:latest
docker.io/library/tomcat:latest
easywhatis$ docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
tomcat              latest              a7fa4ac97be4        2 weeks ago         528MB
easywhatis$ docker ps -a
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES
easywhatis$ docker run --name=tomcat -it -d -p 8080:8080 tomcat
22ff3c787a570407b2d4be8afefb3e68ff858739f8085a7e235c68dd97b8039f
easywhatis$ docker ps -a
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS                    NAMES
22ff3c787a57        tomcat              "catalina.sh run"   3 seconds ago       Up 2 seconds        0.0.0.0:8080->8080/tcp   tomcat
easywhatis$ docker stop tomcat
tomcat
easywhatis$ docker ps -a
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS                       PORTS               NAMES
22ff3c787a57        tomcat              "catalina.sh run"   11 seconds ago      Exited (143) 3 seconds ago                       tomcat
easywhatis$ docker start tomcat
tomcat
easywhatis$ docker ps -a
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS                    NAMES
22ff3c787a57        tomcat              "catalina.sh run"   32 seconds ago      Up 15 seconds       0.0.0.0:8080->8080/tcp   tomcat
easywhatis$