Installing Docker under Linux

Source: Internet
Author: User
Tags docker ps docker run

Today, Daimajia recommends using Docker, but has always listened to Docker, but no use, today refer to a few documents to take Docker. It's faster than the average virtual machine.

This summary is mainly the collation of work, most of the content is in the final document of the article has been described.


My computer is ubuntu14.04 installed.

$ sudo apt-get install apt-transport-https$ sudo apt-key adv--keyserver hkp://keyserver.ubuntu.com:80--recv-keys 36A1D7 869245c8950f966e92d8576a8ba88d21e9$ sudo bash-c "Echo Deb Https://get.docker.io/ubuntu Docker main >/etc/apt/ Sources.list.d/docker.list "$ sudo apt-get update$ sudo apt-get install Lxc-docker

And then according to the article at the end of the given articles.



I started the fedora21, a lot of problems, such as the problem of the Yum source, the command of the lack of problems, and finally replaced with Ubuntu. Ubuntu command is complete, route,ifconfig and other basic commands have been.

Next encounter a problem: No iptables, I installed after the error:

[Email protected]:/# iptables-nliptables v1.4.21:can ' t initialize iptables table ' filter ': Permission denied (you must b e root) Perhaps iptables or your kernel needs to be upgraded.

The solution is to add the following parameter when you start Docker:

--privileged=true
Docker run--privileged=true-t-i Ubuntu_2/bin/bash

Because some features have been disabled ... At first I thought I needed to recompile the kernel and it didn't seem to be necessary.



Here is the network topology diagram for Docker:



Multiple VMs are connected to the DOCKER0 Virtual switch and are connected to the host via port (the noun should be called interface). This topology is not complex. Log in two machine to ping each other, check whether connectivity. Practice proves everything OK.

Again check whether the network can be connected, it turns out to be OK, it seems that Docker has helped us set up a packet nat forwarding.

In fact, Docker topology can be modified, add a network bridge, divide the network and other functions of the second layer, but does not have three layers to add the function of the router.

For example, re-create the bridge and delete the original bridge:

In addition to the default Docker0 bridge, users can specify a bridge to connect to each container.
When starting the Docker service, use-B bridge or--bridge=bridge to specify the bridge to use.
If the service is already running, you need to stop the service and delete the old bridge.

$ sudo service docker stop$ sudo ip link set dev docker0 down$ sudo brctl delbr Docker0

Then create a bridge bridge0.

$ sudo brctl addbr bridge0$ sudo ip addr add 192.168.5.1/24 dev bridge0$ sudo ip link set dev bridge0 up

Review the confirmation bridge creation and launch.

$ IP Addr Show bridge04:bridge0: <BROADCAST,MULTICAST> MTU Qdisc NoOp State up Group Defaultlink/ether 66:38:d 0:0d:76:18 BRD ff:ff:ff:ff:ff:ffinet 192.168.5.1/24 scope global Bridge0valid_lft forever Preferred_lft Forever
Configure the Docker service, which is the default bridge to the created bridge.
$ Echo ' docker_opts= '-b=bridge0 ' >>/etc/default/docker$ sudo service DOCKER start

Start the Docker service. Create a new container and see that it has been bridged to the BRIDGE0.
You can continue to view bridged information with the BRCTL Show command. In addition, IP addr and IP route commands can be used in containers to view IP address configuration and routing information.



One of the more disgusting is that every time you run out of virtual machine if you update resources, remember to leave the virtual machine commit, or the virtual machine will not be saved.

Command:

$ sudo docker commit-m "Changed some resource"-a "myusrname" 0b2616b0e5a8 newvirt
Each of these parameters has the following meanings:

Create a new image from a container ' s changes-a  ,--author= ""     author (e.g., "John Hannibal Smith <[email Protec Ted]> ")  -M,--message=" "    commit message  -P,--pause=true    pause container during Commit
0b2616b0e5a8 is just exiting the container ID and can be obtained via Docker Ps-l-Q

These commands are somewhat similar to git.




There is also a small problem is that every time the input to sudo permissions, God annoying, you can add user groups to solve:

# Add Docker user group $ sudo groupadd docker# add yourself to the Docker user group $ sudo gpasswd-a myusername docker# restart Docker backend service $ sudo service docker restart# logout, and then login $ exit


There are other questions that you can refer to the documentation. The following documents are referenced in this document:

http://yeasy.gitbooks.io/docker_practice/content/image/create.htmlhttps://docker.cn/p/docker-15-tips/http:// ikarishinjieva.github.io/tachikoma-blog/post/2014-07-10-docker-some-error/




Installing Docker under Linux

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.