Created
March 27, 2015 08:01
-
-
Save Dev-Dipesh/3d40ee8dda54ea8a030c to your computer and use it in GitHub Desktop.
A beginner guide to docker for looking up and setting docker image and container
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| DOCKER | |
| ## . | |
| ## ## ## == | |
| ## ## ## ## === | |
| /""""""""""""""""\___/ === | |
| ~~~ {~~ ~~~~ ~~~ ~~~~ ~~ ~ / ===- ~~~ | |
| \______ o __/ | |
| \ \ __/ | |
| \____\______/ | |
| | | | |
| __ | __ __ | _ __ _ | |
| / \| / \ / |/ / _\ | | |
| \__/| \__/ \__ |\_ \__ | | |
| ------------------------------------------------------------------------------------------------------------------ | |
| 1. First try to find docker version to confirm daemon is running | |
| ~$ docker version | |
| Docker Emulator version 0.1.3 | |
| Emulating: | |
| Client version: 0.5.3 | |
| Server version: 0.5.3 | |
| Go version: go1.1 | |
| ------------------------------------------------------------------------------------------------------------------ | |
| 2. Look for available images in the cloud | |
| ~$ docker search tutorial | |
| Found 1 results matching your query ("tutorial") | |
| NAME DESCRIPTION | |
| learn/tutorial An image for the interactive tutorial | |
| ------------------------------------------------------------- | |
| 3. Download Container images using | |
| ~$ docker pull learn/tutorial | |
| Pulling repository learn/tutorial from https://index.docker.io/v1 | |
| Pulling image 8dbd9e392a964056420e5d58ca5cc376ef18e2de93b5cc90e868a1bbc8318c1c (precise) from ubuntu | |
| Pulling image b750fe79269d2ec9a3c593ef05b4332b1d1a02a62b4accb2c21d589ff2f5f2dc (12.10) from ubuntu | |
| Pulling image 27cf784147099545 () from tutorial | |
| ------------------------------------------------------------------------------------------------------------------ | |
| 4. Start a container by running a process in it | |
| ~$ docker run learn/tutorial echo "Hello World" | |
| Hello World | |
| ------------------------------------------------------------------------------------------------------------------ | |
| 5. Install a simple utility ping in the container | |
| ~$ docker run learn/tutorial apt-get install -y ping | |
| Reading package lists... | |
| Building dependency tree... | |
| The following NEW packages will be installed: | |
| iputils-ping | |
| 0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded. | |
| Need to get 56.1 kB of archives. | |
| After this operation, 143 kB of additional disk space will be used. | |
| Get:1 http://archive.ubuntu.com/ubuntu/ precise/main iputils-ping amd64 3:20101006-1ubuntu1 [56.1 kB] | |
| debconf: delaying package configuration, since apt-utils is not installed | |
| Fetched 56.1 kB in 1s (50.3 kB/s) | |
| Selecting previously unselected package iputils-ping. | |
| (Reading database ... 7545 files and directories currently installed.) | |
| Unpacking iputils-ping (from .../iputils-ping_3%3a20101006-1ubuntu1_amd64.deb) ... | |
| Setting up iputils-ping (3:20101006-1ubuntu1) ... | |
| ------------------------------------------------------------------------------------------------------------------ | |
| 6. Save your changes. First find the id of your container | |
| ~$ docker ps -l | |
| ID IMAGE COMMAND CREATED STATUS PORTS | |
| 6982a9948422 ubuntu:12.04 apt-get install ping 1 minute ago Exit 0 | |
| Now commit your changes | |
| ~$ docker commit -author="Dipesh Bhardwaj" -m="Ping Installed" 6982 learn/ping | |
| effb66b31edb <--------- This is new image ID | |
| ------------------------------------------------------------------------------------------------------------------ | |
| 7. Run your new image, let's ping to google | |
| ~$ docker run learn/ping ping www.google.com | |
| PING www.google.com (74.125.239.129) 56(84) bytes of data. | |
| 64 bytes from nuq05s02-in-f20.1e100.net (74.125.239.148): icmp_req=1 ttl=55 time=2.23 ms | |
| 64 bytes from nuq05s02-in-f20.1e100.net (74.125.239.148): icmp_req=2 ttl=55 time=2.30 ms | |
| 64 bytes from nuq05s02-in-f20.1e100.net (74.125.239.148): icmp_req=3 ttl=55 time=2.27 ms | |
| 64 bytes from nuq05s02-in-f20.1e100.net (74.125.239.148): icmp_req=4 ttl=55 time=2.30 ms | |
| -> This would normally just keep going, so we quit here. | |
| ------------------------------------------------------------------------------------------------------------------ | |
| 8. Get the image ID and status of all runnin containers | |
| ~$ docker ps learn/ping | |
| ID IMAGE COMMAND CREATED STATUS PORTS | |
| efefdc74a1d5 learn/ping:latest ping www.google.com 37 seconds ago Up 36 seconds | |
| Now inspect youf docker image | |
| ~$ docker inspect efef | |
| o/p long enough ........ | |
| ------------------------------------------------------------------------------------------------------------------ | |
| 9. Now push images to the Docker Hub Registry, first find all available images in system | |
| ~$ docker images | |
| ubuntu latest 8dbd9e392a96 4 months ago 131.5 MB (virtual 131.5 MB) | |
| learn/tutorial latest 8dbd9e392a96 2 months ago 131.5 MB (virtual 131.5 MB) | |
| learn/ping latest effb66b31edb 10 minutes ago 11.57 MB (virtual 143.1 MB) | |
| Now push your image | |
| ~$ docker push learn ping | |
| o/p pushed | |
| ------------------------------------------------------------------------------------------------------------------ | |
| _ _ _ _ | |
| __ _____| | | __| | ___ _ __ ___ | | | |
| \ \ /\ / / _ \ | | / _` |/ _ \| '_ \ / _ \ | | | |
| \ V V / __/ | | | (_| | (_) | | | | __/ |_| | |
| \_/\_/ \___|_|_| \__,_|\___/|_| |_|\___| (_) | |
| ## . | |
| ## ## ## == | |
| ## ## ## ## === | |
| /""""""""""""""""\___/ === | |
| ~~~ {~~ ~~~~ ~~~ ~~~~ ~~ ~ / ===- ~~~ | |
| \______ o __/ | |
| \ \ __/ | |
| \____\______/ | |
| | | | |
| __ | __ __ | _ __ _ | |
| / \| / \ / |/ / _\ | | |
| \__/| \__/ \__ |\_ \__ | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment