Docker Tutorial 1: Basic use of docker instructions

Similar to the git warehouse, after successful installation,
you can try the commonly used commands one by one
—mydocker is a mirror, and all the mirror names that appear next are related to this
1.docker images List all mirrors
2.docker tag mydocker mydocker2 create A mydocker image named mydocker2
3.docker tag mydocker pengzhengliang/mydocker Create a mirror, plus the warehouse user name
4.docker rmi mydocker2 Delete the mydocker2 image
5.docker ps Get the running container
6.docker ps -a Get all Container and related status information
7.docker run -d -p 8000:5000 mydocker . Start mydocker, use the 5000 port of the computer 8000 port agent itself
8.docker login -u pengzhengliang log in to the pengzhengliang account, and then enter the password, the login will be successful There is login success
9.docker push pengzhengliang/mydocker to push to cloud
10.docker pull pengzhengliang/mydocker to pull mydocker from cloud
11.docker build -t mydocker. Create a docker image in the current directory
12.docker pull mysql to pull mysql image
13.docker run -p 5000:3306 --name pzl-mysql -v ~/mysql/data:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=12345678 -d mysql starts in the background and initializes the password of the root user

Now that the mysql mirror is installed, let's configure remote access to
mysql8 and use it below

GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '12345678' WITH GRANT OPTION;

Use above mysql8

CREATE USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY '12345678';
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' WITH GRANT OPTION;

Then refresh permissions

FLUSH PRIVILEGES;

Then modify the vim /etc/my.cnf configuration file,
find the bind-address parameter in the file, and change its value to the IP address of the MySQL server. If the parameter is commented out, it needs to be uncommented and its value changed to the IP address of the server. For example, changing it to bind-address = 0.0.0.0will allow connections from any host.
That's all for the first time learning the basics

I found that this is not working, so it is not the problem of the mirroring itself, but the problem of the wrong instruction. When I change to compose to create the file that can be connected to compose normally, the
content of the file is as follows

# Use root/example as user/password credentials
version: '3.1'

services:

  db:
    image: mysql
    # NOTE: use of "mysql_native_password" is not recommended: https://dev.mysql.com/doc/refman/8.0/en/upgrading-from-previous-series.html#upgrade-caching-sha2-password
    # (this is just an example, not intended to be a production configuration)
    command: --default-authentication-plugin=mysql_native_password
    restart: always
    environment:
      MYSQL_ROOT_PASSWORD: 12345678
    ports:
      - 5000:3306
    

Refer to
https://www.php.cn/docker/docker-container-usage.html in the future
. I am a dog and I hope you are happy

Guess you like

Origin blog.csdn.net/weixin_38083655/article/details/130028396