Thursday, March 23, 2017

Docker Command Note

Docker Command Note
  • Version
    $ docker --version
    Docker version 1.12.0, build 8eab29e

    $ docker-compose --version
    docker-compose version 1.8.0, build f3628c7

    $ docker-machine --version
    docker-machine version 0.8.0, build b85aac1

  • docker pull ubuntu:14.04 download latest ubuntu image

  • docker images list all images

  • docker run

    • deamon mode :
      docker run -d -p 80:80 [ubuntu(image name)] --name webserver nginx
      -d : Run container in background and print container ID
      -p : Publish a container’s port(s) to the host
      80: out/ 80: in
      –name : Assign a name to the container
      nginx : IMAGE

    • interactive mode :
      docker run -it ubuntu:14.04 | bash
      (啟動一台 ubuntu instance,並且切入bash模式)
      -i: interactive mode, 讓操作者擁有互動模式
      -t: terminal, 讓操作者可以使用終端機操作 instance

  • docker ps show containers just running
    docker ps -a show all containers (default shows just running)

  • docker start start one or more stopped containers

  • docker stop stop one or more running containers

  • docker kill kill one or more running containers

  • docker rm remove one or more containers

  • docker rmi remove one or more images

  • docker port xxxx list port mappings or a specific mapping for the running container

Ubuntu Commands

  • sudo apt-get update
  • sudo apt-get dist-upgrade

No comments:

Post a Comment