Options: --add-host list Add a custom host-to-IP mapping (host:ip) --build-arg list Set build-time variables --cache-from strings Images to consider as cache sources --cgroup-parent string Optional parent cgroup for the container --compress Compress the build context using gzip --cpu-period int Limit the CPU CFS (Completely Fair Scheduler) period --cpu-quota int Limit the CPU CFS (Completely Fair Scheduler) quota -c, --cpu-shares int CPU shares (relative weight) --cpuset-cpus string CPUs in which to allow execution (0-3, 0,1) --cpuset-mems string MEMs in which to allow execution (0-3, 0,1) --disable-content-trust Skip image verification (default true) -f, --file string Name of the Dockerfile (Default is 'PATH/Dockerfile') --force-rm Always remove intermediate containers --iidfile string Write the image ID to the file --isolation string Container isolation technology --label list Set metadata for an image -m, --memory bytes Memory limit --memory-swap bytes Swap limit equal to memory plus swap: '-1' to enable unlimited swap --network string Set the networking mode for the RUN instructions during build (default "default") --no-cache Do not use cache when building the image --pull Always attempt to pull a newer version of the image -q, --quiet Suppress the build output and print image ID on success --rm Remove intermediate containers after a successful build (default true) --security-opt strings Security options --shm-size bytes Size of /dev/shm -t, --tag list Name and optionally a tag in the 'name:tag' format --target string Set the target build stage to build. --ulimit ulimit Ulimit options (default [])
#设置镜像加速 #拉取镜像 docker pull mysql #创建容器 #-p 代表端口映射,格式为 宿主机映射端口:容器运行端口 #-e 代表添加环境变量 MYSQL_ROOT_PASSWORD是root用户的登陆密码 docker run -di --name mysql -p 3306:3306 -e MYSQL_ROOT_PASSWORD=root mysql #进入容器 docker exec -it mysql /bin/bash #登录Mysql mysql -u root -p #查看状态 mysql> status; #进行授权远程连接(注意mysql 8.0跟之前的授权方式不同) mysql> GRANT ALL ON *.* TO 'root'@'%'; #刷新权限 mysql> flush privileges; #此时,还不能远程访问,因为Navicat只支持旧版本的加密,需要更改mysql的加密规则 #更改加密规则 mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'password' PASSWORD EXPIRE NEVER; #更新root用户密码 mysql> ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY 'root'; #刷新权限 mysql> flush privileges; #退出数据库 mysql> exit; #退出容器
1 2 3 4 5 6 7 8 9 10 11 12
docker pull mysql
docker run -di --name mysql -p 3306:3306 -e MYSQL_ROOT_PASSWORD=root mysql docker exec -it mysql /bin/bash mysql -u root -p
GRANT ALL ON *.* TO 'root'@'%'; flush privileges; ALTER USER 'root'@'localhost' IDENTIFIED BY 'password' PASSWORD EXPIRE NEVER; ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY 'password'; flush privileges; exit;
1 2
#docker mysql5.7 docker run -d --name mysql -e MYSQL_ROOT_PASSWORD=root -p 3306:3306 mysql:5.7