Docker Basics : Hello World
To run a 'hello world' program using Docker container.
$ docker run busybox echo hello world
Busybox is a small and lean image. You will see:
Unable to find image 'busybox:latest' locally latest: Pulling from busybox cf2616975b4a: Pull complete 6ce2e90b0bc7: Pull complete 8c2e06607696: Already exists busybox:latest: The image you are pulling has been verified. Important: image verification is a tech preview feature and should not be relied on to provide security. Digest: sha256:38a203e1986cf79639cfb9b2e1d6e773de84002feea2d4eb006b52004ee8502d Status: Downloaded newer image for busybox:latest hello world
We ran a single process in the docker container that echo'ed 'hello world'.
The Busybox image doesn't do much. Let's use a beefier Ubuntu image now.
$ docker pull ubuntu:latest
You will see:
atest: Pulling from ubuntu 428b411c28f0: Downloading [=========================> ] 33.52 MB/65.77 MB 435050075b3f: Download complete 9fd3c8c9af32: Download complete 6d4946999d4f: Download complete
It will take a few minutes to complete.
latest: Pulling from ubuntu 428b411c28f0: Pull complete 435050075b3f: Pull complete 9fd3c8c9af32: Pull complete 6d4946999d4f: Already exists ubuntu:latest: The image you are pulling has been verified. Important: image verification is a tech preview feature and should not be relied on to provide security. Digest: sha256:45e42b43f2ff4850dcf52960ee89c21cda79ec657302d36faaaa07d880215dd9 Status: Downloaded newer image for ubuntu:latest
Docker is a client-server application. It consists of Docker daemon which is the Docker server. It receives and processes incoming Docker API requests. The Docker client is a command line tool that allows us to talk to the Docker daemon via the Docker API. Let's now run the 'hello world' again using the latest Ubuntu.
$ docker run ubuntu echo hello world
You will see: hello world.
In this article, we wrote a simple 'hello world' program using Docker container.
Ace the Technical Interview
- Easily find the gaps in your knowledge
- Get customized lessons based on where you are
- Take consistent action everyday
- Builtin accountability to keep you on track
- You will solve bigger problems over time
- Get the job of your dreams
Take the 30 Day Coding Skills Challenge
Gain confidence to attend the interview