In this post we will see how to create a docker container of ubuntu on your windows laptop.
Pre-requisites:-
I am using “Docker for Windows” software to run dockers on my Windows 10 laptop. You can get “Docker for Windows” by clicking on this link .If you have Windows 7 download Docker Toolbox for Windows with Virtualbox.
Ubuntu docker creation
Once you are done with docker installation let’s move ahead.
We can see our container is created 5 minutes ago and is up. You can also identify the container using the container id. Note that the container ID is same as the first 12 digits of the string we got when we executed docker run in last step.
Once you are inside the Ubuntu container you can explore it. Let’s check the OS version.
Hope this post helped you. Do let us know if you have any query or you get stuck in any installation step.
Once you are done with docker installation let’s move ahead.
- In the windows command prompt or in “Docker Quickstart Terminal” execute below command. By default it will pull the latest image of ubuntu container available in repository.
C:\CloudVedas>docker run ubuntu
- If you need specific version of Ubuntu you can mention the version name in command. Like below we are pulling Ubuntu 14.04 version. You can check all the available versions here .
C:\CloudVedas> docker run ubuntu:14.04Unable to find image 'ubuntu:14.04' locally14.04: Pulling from library/ubuntu2e6e20c8e2e6: Pulling fs layer30bb187ac3fc: Pulling fs layer
- Now let’s see the image we have downloaded .
C:\CloudVedas> docker image lsREPOSITORY TAG IMAGE ID CREATED SIZEubuntu 14.04 6e4f1fe62ff1 4 months ago 197MB
- Let’s create a container with that image using the image id. Here we are using -t and -d option so that the container keeps on running in detached mode and we can login to it.
C:\CloudVedas>docker run -t -d 6e4f1fe62ff1a8dee68d78026adb830edb04391af00ec8b7e1033e711fc640a1489ca54adc0a
- List the running containers using “docker container ls”
C:\CloudVedas>docker container ls
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
a8dee68d7802 6e4f1fe62ff1 "/bin/bash" About a minute ago Up About a minute eager_johnson
We can see our container is created 5 minutes ago and is up. You can also identify the container using the container id. Note that the container ID is same as the first 12 digits of the string we got when we executed docker run in last step.
- Let’s get inside our container and check it.
C:\CloudVedas>docker exec -it a8dee68d7802 /bin/bash
Once you are inside the Ubuntu container you can explore it. Let’s check the OS version.
root@a8dee68d7802:/# more /etc/os-release NAME="Ubuntu" VERSION="14.04.6 LTS, Trusty Tahr" ID=ubuntu ID_LIKE=debian PRETTY_NAME="Ubuntu 14.04.6 LTS" VERSION_ID="14.04" HOME_URL="http://www.ubuntu.com/" SUPPORT_URL="http://help.ubuntu.com/" BUG_REPORT_URL="http://bugs.launchpad.net/ubuntu/" root@a8dee68d7802:/#
- If you don’t see your container up, it may have stopped automatically. To check all the containers which are/were running, execute command
You can also create your own customized container image which you can use to deploy more containers in your environment. Refer this post on how to create a container image. If instead of Docker hub you are using AWS ECR, check the post on how to push/pull image to/from AWS ECR.C:\CloudVedas>docker ps -a
If you want to try next level on docker you can user dockerfile or docker-compose files to install your application. Like in our other post we cover how you can install wordpress in docker.
Hope this post helped you. Do let us know if you have any query or you get stuck in any installation step.
No comments:
Post a Comment