Docker 命令
查看密码 docker run安装完成之后 安装docker logs [mysql 容器名称] SET PASSWORD FOR 'root'@'localhost' = PASSWORD('password123'); 创建新用户9 mysql> CREATE USER 'Zarc'@'localhost' IDENTIFIED BY 'pwd123456'; mysql> GRANT ALL PRIVILEGES ON *.* TO 'jesse'@'localhost' -> WITH GRANT OPTION; mysql> CREATE USER 'Zarc'@'%' IDENTIFIED BY 'pwd123456'; mysql> GRANT ALL PRIVILEGES ON *.* TO 'Zarc'@'%' -> WITH GRANT OPTION; 修改MYSQL 默认字符集: 添加到my.cnf [mysqld] character-set-server=utf8 [client] default-character-set=utf8 [mysql] default-character-set=utf8 Docker run with 环境变量和镜像配置 docker run -d -p 3306:3306 -e"MYSQL_USER=Zarc" -e"MYSQL_PASSWORD=pwd123456" -e"MYSQL_ROOT_PASSWORD=password123" -e "MYSQL_RANDOM_ROOT_PASSWORD=true" --name mysql01 mysql/mysql-server --character-set-server=utf8 --collation-server=utf8_general_ci 备注: : When this is true (which is its default state, unless MYSQL_ROOT_PASSWORD is set or MYSQL_ALLOW_EMPTY_PASSWORD is set to true), a random password for the server's root user is generated when the Docker container is started 当这个MYSQL_RANDOM_ROOT_PASSWORD 为true 时 为root用户设置密码是没有作用的还是会生成随机的密码,设置为false 或者不加这个环境变量 挂载资料卷 用外部mount docker run -d -p 3306:3306 --name mysql01 --mount wtype=bind,src=/docker/mysql/config/my.cnf,dst=/etc/my.cnf --mount type=bind,src=/docker/mysql/data,dst=/var/lib/mysql mysql/mysql-server 用外部volume docker run -d -p 3306:3306 --name mysql01 -v=/docker/mysql/config/my.cnf:/etc/my.cnf -v=/docker/mysql/data:/var/lib/mysql mysql/mysql-server 外部Volume安装mongo on Cent OS docker run -d -p 27017:27017 --name mongo01 -v /docker/mongo/config:/data/configdb -v d:/docker/mongo/db \ Deploy docker registry 本地运行registry仓库 docker run -d -p 5000:5000 --restart=always --name registry registry:2 本地registry - 可视化UI docker run -d --name registry-web --link registry:registry -e ENV_DOCKER_REGISTRY_HOST=registry -e ENV_DOCKER_REGISTRY_PORT=5000 -p 8080:80 konradkleine/docker-registry-frontend:v2 带https证书 (请注意我们host上放证书的文件夹叫cert, not certs) docker run -d \ --restart=always \ --name registry \ -v `pwd`/cert:/certs \ -e REGISTRY_HTTP_ADDR=0.0.0.0:443 \ -e REGISTRY_HTTP_TLS_CERTIFICATE=/certs/1_hub.jessetalk.cn_bundle.crt \ -e REGISTRY_HTTP_TLS_KEY=/certs/2_hub.jessetalk.cn.key \ -p 443:443 \ registry:2 创建密码文件 mkdir auth docker run \ --entrypoint htpasswd \ registry:2 -Bbn testuser testpassword > auth/htpasswd Base Authentication 用户名和密码 docker run -d \ --restart=always \ --name registry \ -v `pwd`/auth:/auth \ -e "REGISTRY_AUTH=htpasswd" \ -e "REGISTRY_AUTH_HTPASSWD_REALM=Registry Realm" \ -e "REGISTRY_AUTH_HTPASSWD_PATH=/auth/htpasswd" \ -v `pwd`/cert:/certs \ -e REGISTRY_HTTP_ADDR=0.0.0.0:443 \ -e REGISTRY_HTTP_TLS_CERTIFICATE=/certs/1_hub.jessetalk.cn_bundle.crt \ -e REGISTRY_HTTP_TLS_KEY=/certs/2_hub.jessetalk.cn.key \ -p 443:443 \ registry:2
干净的卸载docker
yum remove docker \ docker-client \ docker-client-latest \ docker-common \ docker-latest \ docker-latest-logrotate \ docker-logrotate \ docker-selinux \ docker-engine-selinux \ docker-engine rm -rf /etc/systemd/system/docker.service.d rm -rf /var/lib/docker rm -rf /var/run/docker