Monday, December 26, 2016

How to use Docker on Ubuntu


After successfully install docker on ubuntu, next i'm going to show you how to use it, we are going to download our first docker image and run it.

Download the first docker image
To download a docker image from repository, we can use docker pull command, followed by the name of the image you wish to download. For this tutorial let's download docker image called 'busybox'.
sudo docker pull busybox
After the download finish, you can see with docker images command to the if the image really exist
sudo docker images
Running the first docker container
The docker image need to be run before you can use it as container, to run a docker image, simply use the 'docker run' command, followed by the name of the image. For now since we only have one image which is busybox, let's run busybox then.
sudo docker run busybox
If you run the command above, it will wait for second and does nothing, busybox is a very basic container, what you can do is run other command along with it, like this:
sudo docker run busybox echo "hello my friend"
If you want to use the busybox console, run with this instead:
sudo docker run -i -t busybox 
That's just an example of how to use docker on ubuntu, you can try other images on the repo such as ubuntu image itself, this could be your base image, from there you can install many application which then will become a new image, yes you can create your own docker image, it is possible.


No comments:

Post a Comment