docker_practice/image/dockerfile/cmd.md

50 lines
2.9 KiB
Go
Raw Normal View History

### CMD
`CMD` `RUN`
* `shell` `CMD <命令>`
* `exec` `CMD ["可执行文件", "参数1", "参数2"...]`
* `CMD ["参数1", "参数2"...]` `ENTRYPOINT` `CMD`
Docker `CMD`
`ubuntu` `CMD` `/bin/bash` `docker run -it ubuntu` `bash` `docker run -it ubuntu cat /etc/os-release` `cat /etc/os-release` `/bin/bash`
使 `exec` JSON 使 `"`使
使 `shell` `sh -c`
```docker
CMD echo $HOME
```
```docker
CMD [ "sh", "-c", "echo $HOME" ]
```
使 shell
`CMD`
2019-03-08 12:21:07 +08:00
Docker `systemd`
`CMD`
```docker
CMD service nginx start
```
退使 `systemctl`
退退西
使 `service nginx start` upstart `nginx` `CMD service nginx start` `CMD [ "sh", "-c", "service nginx start"]` `sh` `service nginx start` `sh` `sh` 退退
`nginx`
```docker
CMD ["nginx", "-g", "daemon off;"]
```