Installation and deployment of docker on linux

  • 2021-10-16 05:27:28
  • OfStack

After understanding the following article, you can deploy the project on the server. You don't need to install tomcat, jdk, mysql and other servers locally. You can solve it with one key through docker

Installing docker


$ apt install docker.io -y

If the resource cannot be found, you need to update the resource pool. The command is:


$ sudo apt-get update && sudo apt-get upgrade

View docker version


$ docker -v

For more knowledge about docker, please pay attention to: https://www.docker.com/

docker Install mysql


$ docker pull mysql

docker Installing tomcat


$ docker pull tomcat

Start an instance

After docker pulls the above two container images, the image list can be obtained by the following command


$ docker images -a

You can see the two images pulled locally before, and then start the instances of tomcat and mysql respectively. The command is as follows:
Start 1 instance of docker


$ sudo docker run --name image_nick_name image_name:image_tag

Start mysql:


$ sudo docker run --name mysql -p 3400:3306 -e MYSQL_ROOT_PASSWORD=123456 -d mysql:latest

Start tomcat:


$ sudo docker run -it -d --name tomcat tomcat:latest

After startup, tomcat and mysql can be successfully accessed on this server
Connect mysql:


$ mysql -u root -h 114.215.29.39 -P 3400 -p123456

You can visit ip: http://ip: 10050/


Related articles: