zoukankan      html  css  js  c++  java
  • docker第一阶段:入门

    docker configure, not use sudo:
    adduser <user name> docker
    sudo chmod 666 /var/run/docker.sock

    docker build, give the image a tag name:
    docker build -t <tag name> .
    example:
    docker build -t ubuntu .

    docker run:
    docker run -t <tag name>

    docker run in detach mode:
    docker run -d <tag name>

    docker run in detach mode, and bash wait in background:
    docker run -t -d <tag name>

    docker run, give the container a name:
    docker run --name <container name> <tag name>

    docker run, enter bash:
    docker run -t -d --name <container name> <tag name>
    docker exec -t -i <container name> /bin/bash
    example:
    docker run -t -d --name ubuntu ubuntu:18.04
    docker exec -t -i ubuntu /bin/bash

    view all container and images:
    docker ps -a && docker images -a

    remove all containers:
    docker rm $(docker ps -aq) 

    remove all images:
    docker rmi $(docker images -q)

    remove named container:
    docker container rm <container name>

    volume create :
    docker volume create <volumn name>
    docker volume inspect <volumn name>

    volume --mount:
    docker run --mount source=<volume name>,target=/usr/src/myapp <tag name>
    volume --volume:
    docker run --volume ~/Desktop/docker/docker_volume:/usr/src/ <tag name>
    (failed to check files in ~/Desktop/docker/docker_volume)

    volume check:
    docker volume ls

    volume visit:
    cd /var/lib/docker/volumes/dockerVolume/_data

    volume rm:
    docker volume rm <volumn name>

    reference:
    https://stackoverflow.com/questions/30209776/docker-container-will-automatically-stop-after-docker-run-d




  • 相关阅读:
    565. Array Nesting
    796. Rotate String
    817. Linked List Components
    696. Count Binary Substrings
    SQL语句优化
    java7增强的try语句关闭资源
    java新手自己实现的计算器,有点乱
    java数组
    java创建不存在路径的文件
    class.forName
  • 原文地址:https://www.cnblogs.com/hkingsp/p/14430543.html
Copyright © 2011-2022 走看看