• Docker 命令


    查看密码
    docker run安装完成之后 安装docker logs [mysql 容器名称]
       
    
    SET PASSWORD FOR 'root'@'localhost' = PASSWORD('password123');
    
    创建新用户9
    mysql> CREATE USER 'jesse'@'localhost' IDENTIFIED BY 'pwd123456';
    mysql> GRANT ALL PRIVILEGES ON *.* TO 'jesse'@'localhost' WITH GRANT OPTION;
    mysql> CREATE USER 'jesse'@'%' IDENTIFIED BY 'pwd123456';
    mysql> GRANT ALL PRIVILEGES ON *.* TO 'jesse'@'%'
        ->     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 或者不加这个环境变量  
    
     挂载资料卷
    #注意:需要先创建/docker/mysql/config/my.cnf文件和/docker/mysql/data文件夹
    my.cnf如下
    [mysqld]
    user=mysql
    character-set-server=utf8 
    [client]
    default-character-set=utf8 
    [mysql]
    default-character-set=utf8
    
    
    用外部mount 
    
    docker run -d -p 3306:3306 --name mysql01 --mount type=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 --restart always --name db-mysql -v /g/docker/mysql/config/my.cnf:/etc/my.cnf -v /g/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 /docker/mongo/db:/data/db  mongo
    
    
    外部Volume安装mongo on Cent OS //添加外部登录
    docker run -d -p 27017:27017 --name mongo01 -v /docker/mongo/config:/data/configdb -v /docker/mongo/db:/data/db mongodb --auth
    
    docker exec -it mongo01 mongo admin
    
    db.createUser({ user: 'jsmith', pwd: 'some-initial-password', roles: [ { role: "userAdminAnyDatabase", db: "admin" } ] });
    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
    
    
    githlab :基础docker 安装的地址
    https://docs.gitlab.com/omnibus/docker/
    
    提升gitlab-ci runner  permission
    sudo usermod -aG docker gitlab-runner
  • 相关阅读:
    Mybatis分页插件PageHelper使用
    JAVA面试笔记
    基于Fusioncharts的报表统计
    微信支付开发流程
    Java 使用 Jxl 实现 Excel 导入导出
    从navicat中导入sql文件过大:Got a packet bigger than 'max_allowed_packet' bytes
    一个故事告诉你比特币的原理及运作机制
    Linux和Windows下tomcat开机自启动设置
    Linux下安装MySQL
    ubuntu 13.10使用fcitx输入法
  • 原文地址:https://www.cnblogs.com/zengpeng/p/8722590.html
Copyright © 2020-2023  润新知