Download and install docker (Window 10 in this case, you may download the respective docker for your os)

After you installed, you will see the below icon in the right bottom corner indicating your docker daemon is running

Before we start, let learn how to get help:

  • docker run –help
  • docker container –help
  • docker image –help
  • docker help cp

Checking container/image available in your docker:

  • docker info
  • docker container ls or docker ps
  • docker image ls

How to check the name of the docker image in docker hub:

  • docker search –filter is-official=true php
  • docker search cloudera

Some Docker concepts
e.g. docker run hello-world
docker run => to create a new container
hello-world => repository name, if can’t find in your docker repository, then it will download from the docker hub

docker registry -> docker repository -> docker images -> images tags (stacks of layers)

Docker Hub – Community Image repository
Docker Store – Official Image repository

a few more examples:
docker run -it ubuntu bash
docker run -it alpine

Creating and starting a new container Example from ebook Docker in Action

Note: Docker in Action by Jeff Nickoloff is a good book to start, you can grab the ebook from either Amazon/Manning the publisher.

  • Detach flag => to run at background, best for those program or daemon interact with other program or human

docker run –detach –name web ngix:latest
or
docker run -d –name web ngix:latest

another similar example from the ebook docker in action as below:
docker run –detach –name mailer dockerinaction/ch2_mailer

  • Interactive with virtual terminal flag (-it) => Program take input from user or display output on the terminal

docker run -interactive –tty –link web:web –name web_test busybox:latest /bin/sh
or

docker run -i –t –link web:web –name web_test busybox:latest /bin/sh

  • docker run -it –name agent –link web:insideweb –link mailer:insidermailer dockerinaction/ch2_agent

Now we have 3 containers running
docker ps
docker container ls

Below are the images we have created/downloaded so far

docker image ls

Now we can Restart/Stop/Start the containers

  • Start agent
  • Stop agent
  • Restart agent

To test if the system running correclty
docker logs web
docker logs mailer
docker logs agent

Docker Build Process
2 ways – docker container -> docker commit
– dockerfile = blueprint/recipe

dockerfile: similar to below
requirements.txt
package.json
gemfile

Dockerize a Webapp
docker cli
persist data and volumes
networking multiple containers
optimize and clean up
run custom scripts

Dockerize Webapp

Evernote helps you remember everything and get organized effortlessly. Download Evernote.

Related Posts