build
官方說明:用來建立image
常用參數
-t 指定repository:tag docker build . -t repository:tag eg: docker build . it myname/golang:1.14-centos7 -f 指定dockerfile docker build -f dockerfile.debug build with RUL docker build github.com/create/docker-firefox
run
官方說明:用來執行docker
使用概念
- 1 參數
- 2 綁定
- 3 執行的image
常用參數
--interactive,-i Keep STDIN open even if not attached --tty,-t Allocate a pseudo-TTY --ulimit Ulimit options --mount Attach a filesystem mount to the container --add-host Add a custom host-to-IP mapping(host:ip) --attach,-a Attach to STDIN,STDOUT or STDERR --link Add link to another container --name Assign a name to the container --publish,-p Publish a container's port(s) to the host --publish-all, -P Publish all exposed ports to random ports --expose expose a port --rm Automatically remove the container when it exits --ip IPv4 Address --ip6 IPv6 address -w lets the container command being executed inside directory given
Example
Assign name and allocate pseudo-TTY$ docker run --name test -it debianSet working directory
$ docker run -w /path/to/dir/ -i -t ubuntu pwdExporse port 80 of the container without publishing the port to host
Expose port但是沒有連結到host的外面。
$ docker run --expose 80 ubuntu bashPublish a port
把container port 發布到host介面。
這裡是綁定8080到 host tcp 80 on 127.0.0.1
$ docker run -p 127.0.0.1:80:8080/tcp ubuntu bash
沒有留言:
張貼留言