启动MySQL数据库docker镜像设置密码为"123456"
[root@linux-node1 ~]# docker run -it --name=mysql -p 8888:3306 -e MYSQL_ROOT_PASSWORD=123456 mysql
安装mysql客户端便于连接测试
[root@linux-node1 ~]# yum install -y mariadb
[root@linux-node1 ~]# docker exec -it mysql bash
root@9373eb0d5e57:/# mysql -uroot -p123456
Server version: 8.0.16 MySQL Community Server - GPL
mysql> ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY '123456';
Query OK, 0 rows affected (0.01 sec)
mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)
mysql> \q
Bye
[root@linux-node1 ~]# mysql -uroot -h 127.0.0.1 -p'123456' -P 8888
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MySQL connection id is 11
Server version: 8.0.16 MySQL Community Server - GPL
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MySQL [(none)]>
上传Docker镜像到你的Docker Hup仓库
[root@linux-node1 ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
nignx v1 3e5e4a11b5f3 2 hours ago 571MB
sebp/elk latest cd5e6e46d1a2 5 days ago 1.93GB
nginx latest f68d6e55e065 10 days ago 109MB
[root@linux-node1 ~]# docker tag 3e5e4a11b5f3 hotxia/lnmp
[root@linux-node1 ~]# docker login
Login with your Docker ID to push and pull images from Docker Hub. If you don't have a Docker ID, head over to https://hub.docker.com to create one.
Username: hotxia
Password:
WARNING! Your password will be stored unencrypted in /root/.docker/config.json.
Configure a credential helper to remove this warning. See
https://docs.docker.com/engine/reference/commandline/login/#credentials-store
Login Succeeded
[root@linux-node1 ~]# docker push hotxia/lnmp
The push refers to repository [docker.io/hotxia/lnmp]
Content type
Image
Digest
Size
123.4 MB
Last updated
about 7 years ago
docker pull hotxia/mysql-8.0.6