Installation requirements
-
Docker requires a CentOS kernel version later than 3.10. Check the prerequisites on this page to verify that your CentOS version supports Docker. Check your current kernel version with the uname -r command
uname -r
Docker command
-
Query the installed container Docker images
-
Query running Docker DOCker PS
-
Run container docker run container name
-
Stop container Docker Stop Container name
Update the yum!
-
Log in to Centos as user root. Make sure the YUM package is up to date.
sudo yum update
-
Uninstall the old version (if one has been installed)
sudo yum remove docker docker-common docker-selinux docker-engine
-
Install the required package, yum-util provides yum-config-manager functionality, the other two are dependent on the Devicemapper driver
sudo yum install -y yum-utils device-mapper-persistent-data lvm2
-
Set the yum source
Sudo yum – config – manager – add – repo download.docker.com/linux/cento…
Install the docker
-
Query all docker versions in the repository
yum list docker-ce –showduplicates | sort -r
-
Install the docker
Sudo yum install # sudo yum install docker-ce-17.12.0.ce
-
Start and join boot boot
sudo systemctl start docker sudo systemctl enable docker
-
Querying the Docker version Docker version
Install the specified mysql version
-
Query the mysql version in the database hub.docker.com/_/mysql?tab…
-
Install mysql docker pull mysql:5.7
-
Create the MySQL container and start it
Docker run -di –name=mymysql -p 33306:3306 -e MYSQL_ROOT_PASSWORD=123456 mysql:5.7
-p indicates port mapping, in the format of host port mapping: container running port -e indicates adding environment variable MYSQL_ROOT_PASSWORD is the login password of user root ==
-
Query running container docker PS
Install the specified version of Redis
-
Query all Redis versions
docker search redis
-
Pull the latest Redis image
docker pull redis
-
Start the Redis
docker run -d -p 6379:6379 –name myRedis redis:latest
-
Enter the Redis – cli
docker exec -it myRedis redis-cli
Deploy the SpringBoot project
-
Create a new folder in Linux (name yourself)
mkdir back
-
Go to the newly created folder
cd back
-
Copy the Spring Boot JAR package to a folder
SCP/Users/zhanglijie/Desktop/work/md_backend/target/modou. Jar [email protected]: / javaback /
-
Create a Dockerfile file in the current folder
Jar /modou.jar /modou.jar /modou.jar /modou.jar /modou.jar /modou.jar /modou.jar /modou.jar /modou.jar /modou.jar RUN bash -c 'touch /manage_analysis.jar' # EXPOSE 8081 "-jar","/modou.jar"] # Specify MAINTAINER Zhanglijie nameCopy the code
-
Build the image (execute under the current file)
docker build -t mydocker .
==mydocker is the image name: you can choose == at will
-
Run the mirror
Docker run -d -p 4567:8080 mydocker == Docker run -d -p 4567:8080 mydocker == docker run -d -p 4567:8080 mydocker ==
Query spring JAR logs
Stop myDocker and run docker run -p 8081:8081 mydocker
Access to the container
Docker exec it 1ed59d08f032 bash ==1ed59d08f032 ==
Execution: curl localhost: 8083 / modou/user/login