First Steps With Docker

Claudio Procida
Sep 17, 2015 · 5 min read

1. Install Docker Toolbox

The Docker Toolbox Installer for Mac OS X

2. Run Your First Image

The Docker Quickstart Terminal greets us
$ docker run ubuntu:latest echo “hello world!”
Unable to find image ‘ubuntu:latest’ locally
latest: Pulling from library/ubuntu
d3a1f33e8a5a: Pull complete
c22013c84729: Pull complete
d74508fb6632: Pull complete
91e54dfb1179: Pull complete
library/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:73fbe2308f5f5cb6e343425831b8ab44f10bbd77070ecdfbe4081daa4dbe3ed1
Status: Downloaded newer image for ubuntu:latest
hello world!
$ docker run -it ubuntu:latest bash
root@0a76731e26fd:/# ls
bin boot dev etc home lib lib64 media mnt opt proc root run sbin srv sys tmp usr var

3. Build Your Own Image

FROM docker/whalesay:latest
RUN apt-get -y update && apt-get install -y fortunes
CMD /usr/games/fortune -a | cowsay
$ docker build -t docker-whale .
$ docker run -it docker-whale
The output of the docker-whale container

4. Publish Your Image

$ docker login
Username: <enter your username>
Password: <enter your password>
Email: <enter your email>
WARNING: login credentials saved in /Users/delphine/.docker/config.json
Login Succeeded
$ docker images
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
docker-whale latest cb6dccf1ca20 25 hours ago 274 MB
docker/whalesay latest fb434121fc77 3 months ago 247 MB
$ docker tag cb6dccf1ca20 claudiopro/docker-whale:latest
$ docker push claudiopro/docker-whale
Here’s our first image published on Docker Hub

Further Reading

References

Claudio Procida

Written by

Full stack web developer with a keen interest for the open web platform, privacy, security, and IoT. Former Amazonian, former IBMer. All views my own.

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade