Docker 入门

作者: SkTj | 来源:发表于2019-10-28 14:27 被阅读0次

    1、centos7上安装docker
    sudo yum install -y yum-utils device-mapper-persistent-data lvm2
    sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
    sudo yum-config-manager --enable docker-ce-edge
    sudo yum-config-manager --enable docker-ce-test
    sudo yum install -y docker-ce
    sudo systemctl start docker
    sudo systemctl enable docker
    2、更换docker的镜像仓库为私有仓库+daoclound镜像
    curl -sSL https://get.daocloud.io/daotools/set_mirror.sh | sh -s http://f1361db2.m.daocloud.io

    vi /etc/docker/daemon.json

    {
    "registry-mirrors": ["http://f1361db2.m.daocloud.io"],
    "insecure-registries":["192.168.118.77"]
    }

    systemctl daemon-reload

    systemctl restart docker

    3、登录阿里云镜像仓库
    sudo docker login --username=hatqiang registry.cn-shanghai.aliyuncs.com

    4、拉取 docker pull centos:7

    5、运行:
    docker run -itd --name="hatcentos7" centos:7 /bin/bash

    docker rm xxx

    docker rmi imagename

    6、Dockerfile
    docker build -t helloworld .

    7、Docker搭建WorldPress
    docker pull wordpress:latest
    docker pull mysql:latest
    docker run --name mysqlwp -e MYSQL_ROOT_PASSWORD=wordpressdocker
    -e MYSQL_DATABASE=wordpress
    -e MYSQL_USER=wordpress
    -e MYSQL_PASSWORD=wordpresspwd
    -d mysql
    docker run --name wordpress --link mysqlwp:mysql -p 80:80
    -e WORDPRESS_DB_NAME=wordpress
    -e WORDPRESS_DB_USER=wordpress
    -e WORDPRESS_DB_PASSWORD=wordpresspwd
    -d wordpress
    firewall-cmd --zone=public --add-port=80/tcp --permanent
    systemctl restart firewalld.service

    8、删除所有容器
    docker stop (docker ps -q) docker rm -v(docker ps -aq)

    9、docker inspect xx

    10、荣期间共享数据
    docker run -v /data --name data ubuntu:14.04
    docker run -ti --volumes-from data ubuntu:14.04 /bin/bash

    --volumes-from

    11、docker cp
    docker cp xx:/root/file.txt
    docker cp hatcentos7:/test.txt /root/test.txt

    相关文章

      网友评论

        本文标题:Docker 入门

        本文链接:https://www.haomeiwen.com/subject/bggyvctx.html