How to restart the stopped docker/whalesay container?

As Docker for Mac getting started document instructed.

docker run docker/whalesay cowsay boo

  • How to change VOLUME to COPY in Docker?
  • How could I port forward in Docker container?
  • Accessing external hosts from docker container
  • Docker MGT Development Environment and Mailbag
  • Running lxd within docker container having probelms
  • How insert an existing EC2 instance as container host in docker-machine?
  • Every time, I run this, a new container is created, run and stopped.

    CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS                         PORTS                         NAMES
    
    
    0d96e4bd9c14        docker/whalesay     "cowsay boo boo"         11 days ago         Exited (0) 5 minutes ago                                     high_archimedes
    3a079559382e        docker/whalesay     "cowsay boo"             11 days ago         Exited (0) 26 minutes ago                                    boring_ritchie
    

    How could I not create a new container of the docker/whalesay any more but restart existing stopped container of docker/whalesay and get the same result as

    docker run docker/whalesay cowsay boo

    ?

    I tried

    docker start 0d96e4bd9c14
    

    the result only shows

    0d96e4bd9c14
    

    Not the whale image as whalesay would show.

    Thanks!

  • Docker on AWS. ECS or Docker Datacenter
  • How to list images and their containers
  • How to configure spring boot web app with redis using Docker
  • Can a dockerfile make use of a data only container defined in the docker-compose.yml file?
  • Tomcat docker-compose running web app
  • openconnect in dockers/IBM bluemix (Error: TUNSETIFF failed: Inappropriate ioctl for device)
  • 2 Solutions collect form web for “How to restart the stopped docker/whalesay container?”

    The container starts the second time but the difference is that you don’t see the stdout as a default with start

    For example:

    $ docker run docker/whalesay cowsay boo
    Unable to find image 'docker/whalesay:latest' locally
    latest: Pulling from docker/whalesay
    e9e06b06e14c: Pull complete 
    a82efea989f9: Pull complete 
    37bea4ee0c81: Pull complete 
    07f8e8c5e660: Pull complete 
    676c4a1897e6: Pull complete 
    5b74edbcaa5b: Pull complete 
    1722f41ddcb5: Pull complete 
    99da72cfe067: Pull complete 
    5d5bd9951e26: Pull complete 
    fb434121fc77: Already exists 
    Digest: sha256:178598e51a26abbc958b8a2e48825c90bc22e641de3d31e18aaf55f3258ba93b
    Status: Downloaded newer image for docker/whalesay:latest
     _____ 
    < boo >
     ----- 
        \
         \
          \     
                        ##        .            
                  ## ## ##       ==            
               ## ## ## ##      ===            
           /""""""""""""""""___/ ===        
      ~~~ {~~ ~~~~ ~~~ ~~~~ ~~ ~ /  ===- ~~~   
           \______ o          __/            
            \    \        __/             
              \____\______/   
    $ 
    $ sudo docker ps
    CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES
    $ sudo docker ps -a
    CONTAINER ID        IMAGE                    COMMAND             CREATED             STATUS                      PORTS               NAMES
    3230d1589aed        docker/whalesay:latest   "cowsay boo"        32 seconds ago      Exited (0) 31 seconds ago                       evil_curie          
    $ sudo docker start 3230d1589aed
    3230d1589aed
    

    Now check the STATUS that says Exited (0) 2 seconds ago:

    $ sudo docker ps -a
    CONTAINER ID        IMAGE                    COMMAND             CREATED             STATUS                     PORTS               NAMES
    3230d1589aed        docker/whalesay:latest   "cowsay boo"        46 seconds ago      Exited (0) 2 seconds ago                       evil_curie          
    

    You can see the output with docker logs:

    $ sudo docker logs 3230d1589aed
     _____ 
    < boo >
     ----- 
        \
         \
          \     
                        ##        .            
                  ## ## ##       ==            
               ## ## ## ##      ===            
           /""""""""""""""""___/ ===        
      ~~~ {~~ ~~~~ ~~~ ~~~~ ~~ ~ /  ===- ~~~   
           \______ o          __/            
            \    \        __/             
              \____\______/   
     _____ 
    < boo >
     ----- 
        \
         \
          \     
                        ##        .            
                  ## ## ##       ==            
               ## ## ## ##      ===            
           /""""""""""""""""___/ ===        
      ~~~ {~~ ~~~~ ~~~ ~~~~ ~~ ~ /  ===- ~~~   
           \______ o          __/            
            \    \        __/             
              \____\______/ 
    $ 
    

    You can create a new container that is interactive.

    docker run -ti –entrypoint=sh “imageID”

    Replace “imageID” with your image ID. Image IDs can be found by ‘docker images’ command.
    Then you can type a command (e.g., cowsay “say something”) in the prompt as many times as you want. You can exit by typing ‘exit’, it will stop the container. When you want to start the same container, you can start it by

    docker start -i “containerID”

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.