Dcoker entry and practice series of articles
Note: Ubuntu Utopic 14.10 and 15.04 exist in Docker’s APT repository but are no longer officially supported.
$ uname -r
3.11.0- 15- generic
sudo ntpdate cn.pool.ntp.org
$ sudo apt-get update
$ sudo apt-get install apt-transport-https ca-certificates
# Add secret key
$ sudo apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80--recv-keys 58118E89F3A912897C070ADBF76221572C52609D
Add the following entries to the file according to different operating systems
Save and exit
$ sudo apt-get update
Purge the old repo if it exists.
$ sudo apt-get purge lxc-docker
Verify that APT is pulling from the right repository.
$ sudo apt-cache policy docker-engine
From now on when you run apt-get upgrade, APT pulls from the newrepository.
$ sudo apt-get update
Install the recommended package.
$ sudo apt-get install linux-image-extra-$(uname -r)
Go ahead and install Docker.
If you are installing on Ubuntu 14.04 or 12.04, apparmor is required. You can install it using:
sudo apt-get install apparmor
$ sudo apt-get update
$ sudo apt-get install docker-engine
$ sudo service docker start
sudo apt-get install docker-engine=1.10.1-0~trusty
This section contains optional procedures for configuring your Ubuntu to work better with Docker.
$ sudo usermod -aG docker <YOUR_USERNAME>
When we use Docker to run an image, we may see the following information prompt:
WARNING: Your kernel does not support cgroup swap limit. WARNING: Your
kernel does not support swap limit capabilities. Limitation discarded.
In order to prevent the above error messages from appearing, we need to enable memory and swap space in the system. We need to modify the system's GUN GRUB (GNU GRand Unified Bootloader) to enable memory and swap space. The opening method is as follows:
GRUB_CMDLINE_LINUX="cgroup_enable=memory swapaccount=1"
$ sudo update-grub
When you use UFW (simple firewall) on the host where docker is running. You need to do some additional configuration. Docker uses bridging to manage the network. By default, UFW filters all port forwarding policies. Therefore, when using docker with UFW enabled, you must set the UFW port forwarding strategy appropriately.
By default, UFW filters out all inbound rules. If other hosts can access your container. You need to allow all connections on Docker's default port (2375).
Set UFW to allow inbound rules for Docker ports:
$ sudo ufw status
$ sudo nano /etc/default/ufw
DEFAULT_FORWARD_POLICY="ACCEPT"
$ sudo ufw reload
$ sudo ufw allow 2375/tcp
Whether it is Ubuntu or the Ubuntu desktop multiplication version, when the system is running, it uses 127.0.0.1 in the /etc/resolv.conf configuration file as the nameserver. NetworkManager sets dnsmasq to use the real dns server connection, and sets the domain name service of /etc/resolv.conf to 127.0.0.1.
When using these configurations to run docker containers in a desktop environment, Docker users will see the following warning:
WARNING:Local(127.0.0.1) DNS resolver found in resolv.conf and containers
can't use it. Using default external servers :[8.8.8.88.8.4.4]
The warning is because the Docker container cannot use the local DNS service. Instead Docker uses a default external domain name server.
To avoid this warning, you can specify a DNS server for the Docker container. Or you can disable NetworkManager's dnsmasq. However, when dnsmasq is disabled, it may slow down the DNS resolution of some networks.
Specify a DNS server for Docker
$ sudo nano /etc/default/docker
3. Add settings
``` DOCKER_OPTS="--dns 8.8.8.8"```
Use 8.8.8.8 Replace as 192.168.1.1 local DNS server. You can specify multiple DNS servers, and multiple DNS servers are separated by spaces. For example
```- - dns 8.8.8.8 --dns 192.168.1.1```
caveat:If the computer you are using needs to be connected to a different network,Be sure to choose a public DNS server.
$ sudo restart docker
$ sudo nano /etc/NetworkManager/NetworkManager.conf
dns=dnsmasq
$ sudo restart network-manager
$ sudo restart docker
Ubuntu uses systemd as its boot and service manager 15.04 onwards and upstart for versions 14.10 and below.
For 15.04 and up, to configure the docker daemon to start on boot, run
$ sudo systemctl enable docker
For 14.10 and below the above installation method automatically configures upstart to start the docker daemon on boot
To install the latest version of Docker with apt-get:
$ sudo apt-get upgrade docker-engine
# To uninstall the Docker package:
$ sudo apt-get purge docker-engine
# To uninstall the Docker package and dependencies that are no longer needed:
$ sudo apt-get autoremove --purge docker-engine
# The above commands will not remove images, containers, volumes, or user created configuration files on your host. If you wish to delete all images, containers, and volumes run the following command:
$ rm -rf /var/lib/docker
# You must delete the user created configuration files manually.
Recommended Posts