Installation requirements

  1. 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

  1. Query the installed container Docker images

  2. Query running Docker DOCker PS

  3. Run container docker run container name

  4. Stop container Docker Stop Container name

Update the yum!

  1. Log in to Centos as user root. Make sure the YUM package is up to date.

    sudo yum update

  2. Uninstall the old version (if one has been installed)

    sudo yum remove docker docker-common docker-selinux docker-engine

  3. 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

  4. Set the yum source

    Sudo yum – config – manager – add – repo download.docker.com/linux/cento…

Install the docker

  1. Query all docker versions in the repository

    yum list docker-ce –showduplicates | sort -r

  2. Install the docker

    Sudo yum install # sudo yum install docker-ce-17.12.0.ce

  3. Start and join boot boot

    sudo systemctl start docker sudo systemctl enable docker

  4. Querying the Docker version Docker version

Install the specified mysql version

  1. Query the mysql version in the database hub.docker.com/_/mysql?tab…

  2. Install mysql docker pull mysql:5.7

  3. 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 ==

  4. Query running container docker PS

Install the specified version of Redis

  1. Query all Redis versions

    docker search redis

  2. Pull the latest Redis image

    docker pull redis

  3. Start the Redis

    docker run -d -p 6379:6379 –name myRedis redis:latest

  4. Enter the Redis – cli

    docker exec -it myRedis redis-cli

Deploy the SpringBoot project

  1. Create a new folder in Linux (name yourself)

    mkdir back

  2. Go to the newly created folder

    cd back

  3. Copy the Spring Boot JAR package to a folder

    SCP/Users/zhanglijie/Desktop/work/md_backend/target/modou. Jar [email protected]: / javaback /

  4. 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
  5. Build the image (execute under the current file)

    docker build -t mydocker .

    ==mydocker is the image name: you can choose == at will

  6. 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