Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to manage Linux Container Container with Docker in Ubuntu

2025-01-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article focuses on "how to use Docker to manage Linux Container containers in Ubuntu". Interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn how to manage Linux Container containers with Docker in Ubuntu.

In this tutorial, I will show you how to use Docker to manage LXC in Ubuntu 14.04. It is important to note that some of the content of this tutorial may be slightly different from what you have done in other Ubuntu versions.

The installation package for Docker under the current Ubuntu system only provides 64 bits. If you want to run 32-bit Docker, you need to use the source code to compile 32-bit Docker tools.

Install Docker

Installing Docker via apt-get is a piece of cake.

$sudo apt-get install docker.io

If you are not a user of the root group, you can add yourself to the docker group. The following command allows users who do not have root privileges to use Docker:

$sudo usermod-a-G docker $USER

Log in again for your user group permissions to take effect.

The next step is to edit the Docker configuration file to determine the path to the Docker executable:

$sudo vi / etc/default/docker.ioDOCKER= "/ usr/bin/docker.io"

Restart the Docker service:

$sudo service docker.io restart

Manage Docker Container containers

If you want to create a new Ubuntu operating system under the new Docker container, you first need to pull a Docker image of Ubuntu. The following command downloads the Docker image over the network:

$docker pull ubuntu

You can use the following command to start the Ubuntu system in Docker. The parameter "/ bin/bash" of * * indicates that once the container is started, a simple bash will be executed first.

$docker run-I-t ubuntu / bin/bash

The above command immediately starts the Ubuntu container container (this is a * container! And then it will provide you with a shell prompt runtime environment From now on, you can access a complete Ubuntu system through this sandbox environment.

Enter the "exit" command to exit the Docker container.

You can also use the following command to access different systems. For example, Fedora:

$docker.io run-I-t fedora / bin/bash

If the Fedora Docker image does not already exist on the system, this command automatically downloads it and then launches the Fedora's Docker container.

If you want to open a specified version of the system, such as Ubuntu 13.04, you can use the following command:

$docker.io run-I-t ubuntu:13.04 / bin/bash

Container Container Network Settings

Docker uses Linux bridging technology to communicate with other containers and connect to the external network. After installing Docker, you should be able to see the docker0 bridge, which is created by Docker by default. Every container you create will be connected to the network through this bridge.

Custom Linux Brid

If you want to customize the bridge, you can perform the following steps. You can assign a subnet behind the bridge and assign an address to the subnet. The following command assigns the 10.0.0.0and24 address field to the Docker subnet:

$sudo apt-get install bridge-utils$ sudo brctl addbr br0 $sudo ifconfig br0 10.0.0.1 netmask 255.255.255.0

Then add the "- b=br0" option to the DOCKER_OPTS variable in the / etc/default/docker.io file and restart the Docker service:

$sudo service docker.io restart

So far, any containers created will be connected to a br0 bridge, and their IP addresses will be automatically assigned from 10.0.0.0and24.

Other custom settin

You can set some other properties through the DOCKER_OPTS variable in the / etc/default/docker.io file:

"- dns 8.8.8.8-dns 8.8.4.4": specifies the DNS server for the container.

"- icc=false": isolates containers from other containers

Troubleshooting

1. When you run the docker.io command, you may encounter the following problems:

Dial unix / var/run/docker.sock: no such file or directory

This error may be due to the fact that the Docker background process did not start. Check the status of the Docker background process to make sure it is already started:

Sudo service docker.io status$ sudo service docker.io start so far, I believe you have a deeper understanding of "how to use Docker to manage Linux Container containers in Ubuntu". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 286

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report