【Docker学习】Docker 的安装与使用

(持续更新)

安装Docker

  1. 打开控制台使用 uname -r命令来查看你当前的内核版本。
    Docker 要求 Ubuntu 系统的内核版本高于 3.10 ,查看本页面的前提条件来验证你的Ubuntu版本是否支持 Docker 。
  2. 配置Docker的安装源
    依次输入
    sudo apt-get update

    这个可能会有些耗时

    sudo apt-get install apt-transport-https
    sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 36A1D7869245C8950F966E92D8576A8BA88D21E9
    sudo sh -c "echo deb https://get.Docker.com/ubuntu docker main > /etc/apt/sources.list.d/docker.list"

  3. 安装Docker
    sudo apt-get update
    sudo apt-get install lxc-docker

  4. 启动Docker以及配置Docker开机启动
    sudo apt-get install sysv-rc-conf
    sudo sysv-rc-conf docker on
    sudo service docker restart

安装Docker Compose

分两个步骤:
curl -L https://github.com/docker/compose/releases/download/1.3.1/docker-compose-'uname -s'-'uname -m' > /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose

注意:如果你在安装的时候出现了 “Permission denied” 的错误信息,这说明你的 /usr/local/bin
目录是不可写的,你需要使用超级用户来安装。运行sudo -i , 然后运行上边的两个命令,然后 exit 退出。

到这里安装就结束了;Compose已经安装完成。你可以使用docker-compose --version 来进行测试安装是否成功 。

Docker常用指令

  • Docker服务(开始/状态查看/停止/重启)
    service docker + start/status/stop/restart
  • 查看正在运行的容器
    docker ps
    docker ps -a查看包括已经停止的所有容器
  • 查看docker状态
    ps aux | grep docker

下面是一个指令说明介绍

Commands:
    attach    Attach to a running container
    build     Build an image from a Dockerfile
    commit    Create a new image from a container's changes
    cp        Copy files/folders from a container's filesystem to the host path
    create    Create a new container
    diff      Inspect changes on a container's filesystem
    events    Get real time events from the server
    exec      Run a command in a running container
    export    Stream the contents of a container as a tar archive
    history   Show the history of an image
    images    List images
    import    Create a new filesystem image from the contents of a tarball
    info      Display system-wide information
    inspect   Return low-level information on a container
    kill      Kill a running container
    load      Load an image from a tar archive
    login     Register or log in to a Docker registry server
    logout    Log out from a Docker registry server
    logs      Fetch the logs of a container
    port      Lookup the public-facing port that is NAT-ed to PRIVATE_PORT
    pause     Pause all processes within a container
    ps        List containers
    pull      Pull an image or a repository from a Docker registry server
    push      Push an image or a repository to a Docker registry server
    restart   Restart a running container
    rm        Remove one or more containers
    rmi       Remove one or more images
    run       Run a command in a new container
    save      Save an image to a tar archive
    search    Search for an image on the Docker Hub
    start     Start a stopped container
    stop      Stop a running container
    tag       Tag an image into a repository
    top       Lookup the running processes of a container
    unpause   Unpause a paused container
    version   Show the Docker version information
    wait      Block until a container stops, then print its exit code

References

Docker User Guide:https://docs.docker.com/engine/userguide/intro/
Docker中文指南: http://www.widuu.com/docker/index.html
Docker学习笔记: http://www.open-open.com/lib/view/open1423703640748.html
~
~
~
~
~
~
~
~
~

欢迎讨论交流,转载请注明出处。http://blog.csdn.net/zxzxzxzx2121/article/details/53009729

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值