• Docker 创建 mysql 容器


    docker -v
    Docker version 18.06.1-ce, build e68fc7a
     
    拉取 docker mysql 最新的镜像
    docker pull mysql
     
    Using default tag: latest
    latest: Pulling from library/mysql
    a5a6f2f73cd8: Pull complete
    936836019e67: Pull complete
    283fa4c95fb4: Pull complete
    1f212fb371f9: Pull complete
    e2ae0d063e89: Pull complete
    5ed0ae805b65: Pull complete
    0283dc49ef4e: Pull complete
    a7e1170b4fdb: Pull complete
    88918a9e4742: Pull complete
    241282fa67c2: Pull complete
    b0fecf619210: Pull complete
    bebf9f901dcc: Pull complete
    Digest: sha256:b7f7479f0a2e7a3f4ce008329572f3497075dc000d8b89bac3134b0fb0288de8
    Status: Downloaded newer image for mysql:latest
     
     
    docker images
     
    REPOSITORY TAG IMAGE ID CREATED SIZE
    mysql latest f991c20cb508 2 weeks ago 486MB
    hello-world latest e38bc07ac18e 7 months ago
     
     
    docker run -p 3306:3306 --name mysql -v $PWD/data:/var/lib/msql -e MYSQL_ROOT_PASSWORD=****** -d mysql
    c0d6a4dc985c8b5acd43f3883138d9c4aec34c0546c3928fee5ded9ba08c379a
     
    docker: Error response from daemon: driver failed programming external connectivity on endpoint mysql (4b3919e1648f2d1623be615d14ba772979d3c9a86cf90b55308bef32e4cf3507): Error starting userland proxy: listen tcp 0.0.0.0:3306: bind: address already in use.
     
    错误信息,3306 端口已被客户机使用
     
    换个端口再试一次
    docker run -p 3308:3306 --name mysql -v $PWD/data:/var/lib/msql -e MYSQL_ROOT_PASSWORD=**** -d mysql
     
    docker: Error response from daemon: Conflict. The container name "/mysql" is already in use by container "c0d6a4dc985c8b5acd43f3883138d9c4aec34c0546c3928fee5ded9ba08c379a". You have to remove (or rename) that container to be able to reuse that name.
    错误信息,docker name 已被使用
    换个名称再试一次
     
    docker run -p 3308:3306 --name mymysql -v $PWD/data:/var/lib/msql -e MYSQL_ROOT_PASSWORD=***** -d mysql
    5b4ddc12b0dbe0f1e419055bee01ab2838aa4a4d9f69dd28e3f5213a9eed7473
     
    这次没有错误提示,那就是成功了
     
    查看 docker 进程
     
    docker ps
     
    CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
    5b4ddc12b0db mysql "docker-entrypoint.s…" 14 seconds ago Up 10 seconds 33060/tcp, 0.0.0.0:3308->3306/tcp mymysql
     
     
    连接 docker-mysql ,一切征程
     
     
     
    关闭容器
    docker stop mymysql
     
     
     
     
  • 相关阅读:
    Robin Hood CodeForces
    Arthur and Questions CodeForces
    AC日记——过河卒 洛谷 1002
    加密(模拟)
    AC日记——codevs 1086 栈 (卡特兰数)
    AC日记——搞笑世界杯 codevs 1060(dp)
    AC日记—— codevs 1031 质数环(搜索)
    AC日记——产生数 codevs 1009 (弗洛伊德)(组合数学)
    AC日记——阶乘之和 洛谷 P1009(高精度)
    AC日记——逃跑的拉尔夫 codevs 1026 (搜索)
  • 原文地址:https://www.cnblogs.com/hbb0b0/p/10067582.html
Copyright © 2020-2023  润新知