A three   Hospital Medical    test tube  substituting  pregnancy G

 Micro Signal █ █: 138-0226-9370█ █ █ surrogate packet success packet healthy surrogate ████████████ three  A  Hospital Medical    test tube  substituting  pregnancy G

Docker's basic usage

When using the docker, you first need to install the docker. After installation is complete, by downloading from the system environment dockerhub image, and then run the appropriate Image, completion of the running operation of the docker.

During operation of the docker, the image is invoked by docker command of the operation, image run entity called the container. The relationship between image and more like the relationship of the container system of Internet cafes, Internet cafes open system the opportunity to load the operating system, and the user can operate and modify the operating system; when the system shutdown reboot, re-boot the system does not retain the user's changes will restore the original state of the original system. Docker's the same process with the use of container image starts in the docker, users will not be saved in operating container made, but cleared when the user exits.

If the user wishes to modify container is stored at, you will need to save the container into a new image, realize save changes; or use a form of shared disk, the shared directory external systems to the internal container, share changes will be on the disk They are reserved.

Download image from Docker Hub

docker provides the image to download the official channels dockerhub, address: https: //hub.docker.com.

With Ubuntu, for example, on dockerhub, you can find the image of the Ubuntu download page] [https://hub.docker.com/_/ubuntu, you can see a lot of information about the different versions of Ubuntu on this page, by

docker pull ubuntu

 

Ubuntu can download the latest complete image, you can also look for according to the desired image tag by tag page, the specified image to download. For example, download Ubuntu image 1804, the command is as follows:

docker pull ubuntu:18.04

 

After the download is complete, you can see the local downloaded image by docker images command.

REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
ubuntu              18.04               7698f282e524        4 weeks ago         69.9MB

 

Since this image is only a minimal system environment, the package comprising installation command apt, so the image is small. If the subsequent need to install additional software packages, and creating a new image, a new image size increases.

Run image

Use docker run image command as follows:

docker run ubuntu:18.04 bash

 

The above command is through docker called ubuntu: 18.04image in bash. But the command flash, without leaving any trace. This is not a run-time error, but because after the run is completed out of the bash. If you do not want to quit running, but remained in the terminal can be executed by the following command:

docker run -it ubuntu:18.04

 

After the above command finishes running, you can stay in the shell, the shell is docker running Ubuntu image of the container's shell, you can see the command prompt as follows:

root@7ab5341e698c:/# 

 

After entering the container, the user is root, container number 7ab5341e698c, staying directory is "/." Next, you can perform various operations in the container may be required to install their own software using apt command.

 

! ! note! !

When you exit the container, if used directly lead to the exit command to exit the container, all changes will be lost inside the container. If you just want to leave the window without exiting the container, it is necessary to use "ctrl + p, ctrl + q" This set of commands to leave the container, the container will remain running in the background. Container in state run in the background by "docker ps" to view, for example:

$ docker ps
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES
7ab5341e698c        ubuntu:18.04        "/bin/bash"         About an hour ago   Up About an hour                        vigilant_kapitsa
 

Can be seen by the above command, the vessel runs in the background, the command ID is "7ab5341e698c". If you wish to enter into the container again, you can enter the command again by attach to the container. E.g:

docker attach 7ab5341e698c

 

Once again returned to the vessel, the vessel will continue to see the status of the implementation of the internal shell. If returned to the vessel, the interior of the container shell command is being executed, it will be stuck at the shell. When the shell stuck, by "ctrl + c" command to end the current run command, can also "ctrl + z" command to the program execution is suspended by "fg" resume the suspended program when it is run.

Note that, when the container is running, a plurality of windows attach command via the container, will enter into the same shell, the shell results in preemption, it is possible to attach a plurality of operatively connected with a container.

Save container

During the docker operation, after installing the software tools you need to, you can "docker diff containner" command to see what has changed, for example:

Copy the code
$ docker ps
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES
7ab5341e698c        ubuntu:18.04        "/bin/bash"         About an hour ago   Up About an hour                        vigilant_kapitsa

$ docker diff 7ab5341e698c
C /root
C /root/.viminfo
A /root/.vimrc
Copy the code

 

Through the above commands, it can be seen in the container, and added viminfo vimrc file. To save these changes, you can commit command to save the container into a new image. Command is as follows:

docker commit -m "Add vimrc and viminfo" 7ab5341e698c myubuntu_1804:v0.1

 

The previous commands, achieved by container 7ab5341e698c create a name for the myubuntu_1804, tag to the image v0.1. Docker next run time, you can run the image directly. Run the following command:

docker run -it myubuntu_1804:v0.1

 

By container of the image running, including changes to the viminfo before and vimrc achieve the preservation of the original container.

MacOS

On MacOS, the default file system is not case-sensitive, this problem will be compiled for Linux, the need to create a case-sensitive expansion disk to store buildroot project files.

On MacOS, through the disk management tool that can be added to a new dossier on the original disk on the original disk. The files can be shared with the original disk storage space, but also has a separate disk format.

When you add files, the disk format is set to "APFS case sensitive" to create a new case-sensitive dossiers. So far, the preparatory work on the MacOS disk ready.

Compile Buildroot

Buildroot framework to quickly build an embedded Linux system on a Linux platform that can be configured using menuconfig, rapid build tools Linux tool chain, rootfs and other environments.

You can be downloaded from the official website Buildroot to Buildroot source package, URL: https: //buildroot.org/download.html. Decompressed after the download is complete, you can get the working directory of Buildroot.

In this directory, the directory exists configs, which contains the default config information can be achieved quickly constructed by the default configuration.

Hereinafter, the use of "qemu_mips64el_malta_defconfig" as the default configuration, will be described using the basic method of Buildroot.

Docker shared disk

To be able to use Buildroot within the docker, by using the form Buildroot shared disk will mount inside docker, instead of the internal Buildroot placed in a container file system. This can easily compile the results Buildroot reservations, without by saving form of container to save the changes.

Due to the use as a shared disk Buildroot storage environment, so it is necessary to note that:

The disk must be case-sensitive! ! Otherwise, the software package will compile error! !

The disk must be case-sensitive! ! Otherwise, the software package will compile error! !

The disk must be case-sensitive! ! Otherwise, the software package will compile error! !

You can mount the shared directory to the internal container with the following command:

docker run -it -v ${PWD}:/dockershare myubuntu_1804:v0.1

 

In the above command, $ {PWD} refers to the current directory (full path), "/ dockershare" refers to the internal container can see the shared directory path (full path). After completion of the above-described command, the current directory can be mounted to the inside docker container, can also be $ {PWD} replaced with another full path to achieve the specified loading path.

Note that, the path must be stored external Buildroot path, and the path can be stored in a file case-sensitive.

Configuration

By loading a shared disk into the container, you can enter "/dockershare/buildroot-2019.05" path (This article is 2019.05 download version Buildroot), in the path, can be quickly configured in the form of a direct call defconfig, such as:

make qemu_mips64el_malta_defconfig

 

After configuration, you need to adjust some option information, you can "make menuconfig" to enter the menu, make changes.

Here you can adjust the default package repository to download Buildroot backup repository, which can speed up the download speed, avoid part of the package can not be downloaded. Configuration adjustment path is as follows:

Copy the code
  │ Symbol: BR2_PRIMARY_SITE [=http://sources.buildroot.net]                │  
  │ Type  : string                                                          │  
  │ Prompt: Primary download site                                           │  
  │   Location:                                                             │  
  │     -> Build options                                                    │  
  │       -> Mirrors and Download locations
  
将该值设置为“http://sources.buildroot.net”
Copy the code

 

After modifying the configuration, you can be back by ecs, to the last level prompted to save the configuration information can be saved when you exit.

Compile

After configuration is complete, you can enter the compilation step. Compiler command is as follows:

make source # package will advance all downloads, can be omitted 
make # compile

 

Said compiling step, "make source" may be omitted. But through all the download packages "make source" may be required to compile, compile follow-up can reduce the compilation process of compiling the package can not be downloaded because the cause of the suspension. "Make source" may not be performed, so that the process of compiling, the time required to compile a package to download, is also possible.

Buildroot can "make" command compile, after compiling, storing the compiled results in the output directory. At this point, all operations end.

 

Guess you like

Origin www.cnblogs.com/daiyungongsi01/p/11041020.html