How to restart the stopped docker/whalesay container?

As Docker for Mac getting started document instructed.

docker run docker/whalesay cowsay boo

  • DHCP interface on docker
  • Config files are “reset” on computer restart for Docker/Kitematic on Windows
  • Seeing protocol error with ln for mounted volume inside docker
  • docker exec not working in docker-compose containers
  • Docker Swarm and private IP
  • Active directory accounts inside a windows container (server 2016 TP5)
  • 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-Mongodb - How to connect to the mongo image in local(windows)
  • Docker doesn't start MONGODB, and IPAddress doesn't appear, when started with other services
  • Where should i run my grunt build step when building my docker image for staging and production environments?
  • Mail server docker with certbot
  • Appending to PATH in a Windows Docker container
  • Attaching process to Docker libcontainer container
  • 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.