Docker container technology

* 

ps :

I. Overview

  • Docker is an open source engine, you can easily create a lightweight for any application, portable, self-contained container. Developers in a notebook compiled by the test container can batch deployed in a production environment
17149157-578fbeb7979646a6.png

II: Core Concepts

  • Host : A host machine docker program installed (Cocker mounted directly on the operating system)
  • Client : Connecting the host operating docker
  • Registry : To save all kinds of packaged software image
  • Images : Packaged software mirroring, on the docker warehouse
  • Container : An example of the image starts is called a container, the container is a stand-alone application or a group of
17149157-072275686e26dd2c.png

Three: Installation docker

(A) check the linux kernel version

  • Must be 3.10 or above
uname -r

(B) mounting docker

yum install docker
  • Enter yConfirm Installation

(C) start docker

# 启动docker
systemctl start docker
# 查看版本号
docker -v

(Iv) boot configuration

systemctl enable docker

(E) stop docker

systemctl stop docker

Four: Common Commands

(A) the mirroring

operating command Explanation
Seek docker search 关键字 Search Mirror, also in dockerhub search for detailed information on
Pull docker pull 镜像名:tag :tagIs optional, tagrepresents a label, usually version, the default islatest
List docker images View all local mirror
delete docker rmi image-id Delete the specified local mirror

(B) operating the vessel

1. Search Mirror

docker search tomcat

2. Pull the mirror

docker pull tomcat

3. The image starting container

docker run --name mytomcat -d tomcat:latest
  • --name : Assign a name to the container
  • -d : --detach,Run container in background and print container ID

4. Check the operation of the vessel

docker ps

The container is stopped in operation

docker stop container-id

6. Check all containers

docker ps -a

7. Start container

docker start container-id

8. Remove the container

docker rm container-id

9. Port Mapping

docker run -d -p 8888:8080 tomcat
  • -d : Background process
  • -p: --publish list, The Publish apos Container Port A (S) The Host to (default []), will be released to the host port of the container port (host port: the port of the container)

10. The open port 8888

firewall-cmd --zone=public --add-port=8888/tcp --permanent
  • --zone : Scope
  • --add-port=8888/tcp : Add the port in the format: port / protocol
  • --permanent : Permanent

11. Log

docker logs container-name/container-id

(C) install mysql

1. Pull mirror

docker pull mysql

2. Start

docker run --name mysql01 -d -p 3306:3306 mysql
  • Rom found !!!

3. View Log

docker logs mysql01
error: database is uninitialized and password option is not specified 
  You need to specify one of MYSQL_ROOT_PASSWORD, MYSQL_ALLOW_EMPTY_PASSWORD and MYSQL_RANDOM_ROOT_PASSWORD
  • Database is not initialized, the cryptographic operation is not described
  • You need to describe one of these three variables

4. Start the specified variable

docker run --name mysql02 -d -p 3306:3306 -e MYSQL_ROOT_PASSWORD=123456 mysql
  • -e : --env list,Set environment variables (default [])

The client connection

1) into the mirror

docker exec -ti 2cbb0f246353 /bin/bash

2) Log

mysql -uroot -p123456

3) modify the root login address

ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY '123456';

Five: the use of summary docker step

  1. Installation Docker
  2. Docker warehouse to find the software corresponding to the image;
  3. Docker run using this image, this image will generate a Docker containers;
  4. Start to stop the vessel is to start the software stops;

Reproduced in: https: //www.jianshu.com/p/52c59cabf2b7

Guess you like

Origin blog.csdn.net/weixin_33851429/article/details/91213788