見出し画像

Starting a docker container

  Let's get our hands dirty and kick start a docker container with busybox, an image you can download from docker hub and run a bash command within the container.  

#Input
docker run busybox echo hello world

#Output
hello world

If this is your first time starting this instance, the docker client will talk to the docker hub and download the required image to your local laptop. This takes a few seconds to a few minutes depending on your internet speed. 

We can check the containers running  and stopped by executing docker ps command.

docker ps --all 
#Output
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS                      PORTS               NAMES
dbce165b309b        busybox             "echo hello world"       16 hours ago        Exited (0) 16 hours ago                         lucid_ramanujan
3780aa4187ff        redis               "docker-entrypoint.s…"   17 hours ago        Exited (0) 16 hours ago                         nostalgic_ride
4f0f7373f805        redis               "docker-entrypoint.s…"   17 hours ago        Exited (0) 17 hours ago                         kind_napier
42a98806e4d1        busybox             "ping google.com"        17 hours ago        Exited (137) 17 hours ago                       goofy_bassi

As you can see above, there were four containers running. "docker ps --all" shows you the history of all docker containers.  To show the history of the last container, just execute "docker ps".  We will talk more about stopping docker containers in the next lecture.

いいなと思ったら応援しよう!