And software configuration common operations Docker

yum update: upgrade all packages as well as software upgrades and system kernel

yum upgrade: upgrade all packages only, not upgrading software and system kernel

Installation docker: yum install docker

Start docker Services: systemctl start docker

Set docker service boot from the start: systemctl enable docker way to determine if prompted, press Y and Enter.

Test whether the installation was successful docker: docker ps -a 

Container operation:

docker stop container id

docker start container id

docker restart container id

Lists all currently running: docker ps

View all containers, including the closure of: docker ps -a

What some view current images: docker images

下载image:docker pull image-name

Delete images, specified by id image deletion Who: docker rmi <image id>

Force the removal of the container, regardless of whether you are running: Docker RM - f

 

A: Installing MySQL

docker pull mysql:5.71:

Create mysql: 5.7 Data storage directory

  mkdir /data/docker/mysql1

         cd  /data/docker/mysql1

mkdir data

2: Create a temporary msyql: 5.7 container, the aim cp container mysql configuration file

3: Copy mysql container configuration file to the specified directory host

4: Copy the files out of the container from the command:

  dokcer cp container name: container directories need to copy files or directories docker cp myMysql: / etc / mysql / data / docker / mysqle1 copied directory structure (be careful not to modify the mysql directory after copy, otherwise the contents inside the profile required re repair

 

 

 5: Delete temporary mysql container (rm -f stop and delete)

docker rm -f myMysql

6: We configured startup command execution

 

docker run -d --name mysql1 -p 33306:3306 --restart always --privileged=true -v /data/docker/mysql1/mysql:/etc/mysql -v /data/docker/mysql1/data:/var/lib/mysql -e MYSQL_USER="lwj" -e MYSQL_PASSWORD="123456" -e MYSQL_ROOT_PASSWORD="admin123" -v /etc/localtime:/etc/localtime mysql:5.7

 

7: command interpreter:

--restart always -> boot 
 --privileged = to true   -> the hoisting container permissions 
 -v / data / docker / mysql1 / mysql: / etc / mysql -> mapping configuration file 
 -v / data / docker / mysql1 / data: / var / lib / MySQL -> map data directory 
 -e mysql_user = " lwj "    -> Add user lwj
 -e MYSQL_PASSWORD = " 123456 "    -> set lwj user's password is 123456
 -e MYSQL_ROOT_PASSWORD = " admin123 " -> set the root the password is admin123

2 Install Tomcat

docker pull tomcat:8.5

docker run -d -p 8081:8080 --name tomcat1 --restart=always -v /data/docker/nginx/www:/home -v /data/docker/tomcat1/root:/root -v /data/docker/tomcat1/webapps:/usr/local/tomcat/webapps -v /etc/localtime:/etc/localtime --network network1 tomcat:8.5

docker run -d -p 8082:8080 --name tomcat2 --restart=always -v /data/docker/nginx/www:/home -v /data/docker/tomcat2/root:/root -v /data/docker/tomcat2/webapps:/usr/local/tomcat/webapps -v /etc/localtime:/etc/localtime --network network1 tomcat:8.5

Into the container

docker exec -it “CONTAINER ID”/bin/bash

The time zone added to the list

echo "Asia/Shanghai" > /etc/timezone

Exit container

exit

Restart container

docker restart “CONTAINER ID”

 

Guess you like

Origin www.cnblogs.com/lwjQAQ/p/12603610.html