create account

Neoxian's guide to Docker by neoxian

View this thread on: hive.blogpeakd.comecency.com
· @neoxian · (edited)
$15.99
Neoxian's guide to Docker
https://d3nmt5vlzunoa1.cloudfront.net/phpstorm/files/2015/10/large_v-trans.png


No, this isn't a Steemit whale, it's the Docker whale! from https://www.docker.com/

I'm just going to share with you some basics of using docker.  I found it very handy when setting up my Steem Witness node.

# What is it?

Docker allows you to run a virtual, contained system.  It is a little bit like VMWare or Virtual box, except those two emulate computer hardware where as Docker can make use of your existing OS kernel.  This makes Docker much more lightweight and lean, but still gives you contained, virtual operating system.

# Installing
First you have to install docker.  I'm not going to go into too much detail for this.  If you are on Linux, you can use the package management system and install.  

For windows, you can get it from here: https://docs.docker.com/docker-for-windows/

Some caveats, you'll need 64 bit windows 10 pro for this, and you may have to go into the Bios and turn virtualization on.

# Making sure it works

You'll want to run the command 
`docker info`

You should get something like this:
`neo@hanxia ~ $ docker info`
 `Containers: 1`
 `Running: 1`
 `Paused: 0`
 `Stopped: 0`
 `Images: 4`
 `Server Version: 1.12.6`
 `Storage Driver: aufs`
etc..

If you don't get this, then something is not working.  You may have to start the Docker daemon, and/or put your user in the 'docker' group.

The next basic thing you can do is to run a simple container:
`docker run hello-world`

What this does is to download a simple container and then run it.  
https://i.imgsafe.org/b8ed7a1b42.png


# Image management
A docker image is a blueprint for a container.  A container is the thing that actually runs.  To see what images you have taking up your disk space, do

https://i.imgsafe.org/b8db21e344.png

 You can see here that I have three images.  If I want to remove an image I don't need, I can do:

`docker rmi hello-world`
That will remove the 'hello-world' image.

How did I get that "ubuntu 16.04" image?  You can do:
`docker pull ubuntu:16.04`
This image is very useful for compiling Steemd you need for a witness node.

# Container management
A container is a running instance that is created from an image.  Let's say we want to run an instance of ubuntu 16.04 .  We can do:
https://i.imgsafe.org/b945a66cca.png
`docker run --name myubuntu -it ubuntu:16.04 /bin/bash`

Ok, I used "--name" to give my container a name.  Otherwise docker will give it some funny name.  "-it" means to make it an interactive terminal.  "ubuntu:16.04" is what image I wanted to run.  And of course I want to run a nice bash shell.

You can see that I'm "root" in this little system, the hostname is the pithy "92dc248fb1d6" and it has it's own file system.

Let's make a tiny change to this running container:
https://i.imgsafe.org/b96e378206.png

Now it has a "steemit" file...

You can exit the shell using "exit" which will also stop the container, but it's still there.
Use
`docker ps -a` to show all the containers, even if they are not running at the moment (the -a).
https://i.imgsafe.org/b9912ccd0d.png

We can run a second container from the same ubuntu:16.04 image and call it "myubuntutwo".
https://i.imgsafe.org/b9a1f789ce.png

You'll notice that it does not have the "steemit" file we added.  This is a different container!

"exit" the container and list them again:
https://i.imgsafe.org/b9b0b966f1.png
There is our two containers!

Now if we want to get back in our first container, we do:
https://i.imgsafe.org/b9ba37b896.png

`docker restart myubuntu`
`docker attach myubuntu` then hit return.

And look, our "steemit" file is back!

Let's say you want to open up a second terminal into this container without closing the first one. You can do:
`docker exec -it myubuntu bash`
https://i.imgsafe.org/b9cf350a4a.png

If you have too many containers running and want to get rid of one, do:
`docker rm myubuntutwo`

This will delete the "myubuntutwo" container, be careful with this sort of thing.

Ok, phew, one last command for now, I promise.  Supposing we really like the "myubuntu" container we made, with our change to it (the steemit file) and we want to save this as an image, or template for future containers.  You can run this command:
`docker commit myubuntu neoxian/myubuntu`
https://i.imgsafe.org/b9f278fa63.png

We have taken the "myubuntu" container and created the image "neoxian/myubuntu".   The new image shows up when you run `docker images`.

# You now have Docker Kung-fu!

Clearly this just scratches the surface of Docker, there is way more to it, and I'm still just a noob myself, but this guide should help get you started.

# Happy Dockering!

https://i.imgsafe.org/ba02d85c63.gif
👍  , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , and 148 others
👎  
properties (23)
authorneoxian
permlinkneoxian-s-guide-to-docker
categoryprogramming
json_metadata{"tags":["programming","docker","guide"],"image":["https://d3nmt5vlzunoa1.cloudfront.net/phpstorm/files/2015/10/large_v-trans.png","https://i.imgsafe.org/b8ed7a1b42.png","https://i.imgsafe.org/b8db21e344.png","https://i.imgsafe.org/b945a66cca.png","https://i.imgsafe.org/b96e378206.png","https://i.imgsafe.org/b9912ccd0d.png","https://i.imgsafe.org/b9a1f789ce.png","https://i.imgsafe.org/b9b0b966f1.png","https://i.imgsafe.org/b9ba37b896.png","https://i.imgsafe.org/b9cf350a4a.png","https://i.imgsafe.org/b9f278fa63.png","https://i.imgsafe.org/ba02d85c63.gif"],"links":["https://www.docker.com/","https://docs.docker.com/docker-for-windows/"],"app":"steemit/0.1","format":"markdown"}
created2017-02-08 22:52:51
last_update2017-02-09 01:38:54
depth0
children4
last_payout2017-03-12 03:20:42
cashout_time1969-12-31 23:59:59
total_payout_value12.875 HBD
curator_payout_value3.117 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length4,719
author_reputation167,513,329,359,448
root_title"Neoxian's guide to Docker"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id2,457,914
net_rshares45,270,956,847,436
author_curate_reward""
vote details (213)
@bullionstackers ·
$0.02
Good to know dockering
👍  , , ,
properties (23)
authorbullionstackers
permlinkre-neoxian-neoxian-s-guide-to-docker-20170208t232517034z
categoryprogramming
json_metadata{"tags":["programming"],"app":"steemit/0.1"}
created2017-02-08 23:25:18
last_update2017-02-08 23:25:18
depth1
children0
last_payout2017-03-12 03:20:42
cashout_time1969-12-31 23:59:59
total_payout_value0.018 HBD
curator_payout_value0.001 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length22
author_reputation163,180,943,634,376
root_title"Neoxian's guide to Docker"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id2,458,131
net_rshares655,592,122,434
author_curate_reward""
vote details (4)
@timcliff ·
$0.02
Thanks for the info! Curious, if you are already running an Ubuntu machine, are there any benefits to running everything through Docker?
👍  
properties (23)
authortimcliff
permlinkre-neoxian-neoxian-s-guide-to-docker-20170208t230726009z
categoryprogramming
json_metadata{"tags":["programming"],"app":"steemit/0.1"}
created2017-02-08 23:07:24
last_update2017-02-08 23:07:24
depth1
children2
last_payout2017-03-12 03:20:42
cashout_time1969-12-31 23:59:59
total_payout_value0.019 HBD
curator_payout_value0.001 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length136
author_reputation272,954,445,077,789
root_title"Neoxian's guide to Docker"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id2,458,024
net_rshares642,514,572,178
author_curate_reward""
vote details (1)
@neoxian ·
$0.02
Two advantages:
* Security: the container is a sandbox, so if it get hacked, the damage is limited to the container and not the whole system.
* Repeatability:  with a container, you can have a known system that has everything you need for your application and little to no extra cruft, so you can compile, run and debug your apps in a more consistant way.  You don't have to worry about hundreds of different types of linux distributions or windows setups that have become 'unique' over time.
👍  , , ,
properties (23)
authorneoxian
permlinkre-timcliff-re-neoxian-neoxian-s-guide-to-docker-20170208t231423830z
categoryprogramming
json_metadata{"tags":["programming"],"app":"steemit/0.1"}
created2017-02-08 23:14:24
last_update2017-02-08 23:14:24
depth2
children1
last_payout2017-03-12 03:20:42
cashout_time1969-12-31 23:59:59
total_payout_value0.018 HBD
curator_payout_value0.003 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length492
author_reputation167,513,329,359,448
root_title"Neoxian's guide to Docker"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id2,458,067
net_rshares685,813,448,572
author_curate_reward""
vote details (4)
@timcliff ·
Cool, thanks!
properties (22)
authortimcliff
permlinkre-neoxian-re-timcliff-re-neoxian-neoxian-s-guide-to-docker-20170208t231752634z
categoryprogramming
json_metadata{"tags":["programming"],"app":"steemit/0.1"}
created2017-02-08 23:17:51
last_update2017-02-08 23:17:51
depth3
children0
last_payout2017-03-12 03:20:42
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length13
author_reputation272,954,445,077,789
root_title"Neoxian's guide to Docker"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id2,458,091
net_rshares0