docker_practice/appendix/faq/README.md

215 lines
10 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

#
##
###
使 `docker image prune`
###
使 `docker run IMAGE env`
###
Docker `/var/lib/docker/` `aufs` `container` `graph` `aufs`
### Docker
* debian:wheezy debian:stretch
*
*
* 使
*
* 使 Dockerfile .dockerignore 使
[Dockerfile ](../best_practices.md)
### pull http_proxy
Docker `export http_proxy="http://<PROXY_HOST>:<PROXY_PORT>"` Docker
##
### 退 docker container ls
退exited `docker container ls -a` `docker start`
###
使 `docker stop $(docker container ls -q)`
###
使 `docker container prune`
### PID
使 `docker inspect --format '{{ .State.Pid }}' <CONTAINER ID or NAME>`
### IP
使 `docker inspect --format '{{ .NetworkSettings.IPAddress }}' <CONTAINER ID or NAME>`
### IP IP
使使 IP
```bash
$ docker network create -d bridge --subnet 172.25.0.0/16 my-net
$ docker run --network=my-net --ip=172.25.3.3 -itd --name=my-container busybox
```
### 退
`Ctrl-p Ctrl-q` `Ctrl-c`
### 使 `docker port` Error: No public port '80' published for xxx
* `Dockerfile` `EXPOSE`
* `PublishAllPort = true`
###
`supervisord` https://docs.docker.com/config/containers/multi-service_container/ 。
### CPU
使 `docker create` 使 `docker run` 使 -c|--cpu-shares[=0] 使 CPU 使 -m|--memory[=MEMORY] 使
##
### RepositoryRegistryIndex
##
### Docker
使 `systemd` Ubuntu 16.04Centos `/etc/docker/daemon.json`
### Docker
Docker `/var/lib/docker` Docker 使 Linux daemon `-g` `/etc/docker/daemon.json` "data-root" 使 `docker system info | grep "Root Dir"` 使
/storage/docker
```sh
[root@s26 ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VolGroup-lv_root 50G 5.3G 42G 12% /
tmpfs 48G 228K 48G 1% /dev/shm
/dev/sda1 485M 40M 420M 9% /boot
/dev/mapper/VolGroup-lv_home 222G 188M 210G 1% /home
/dev/sdb2 2.7T 323G 2.3T 13% /storage
[root@s26 ~]# service docker stop
[root@s26 ~]# cd /var/lib/
[root@s26 lib]# mv docker /storage/
[root@s26 lib]# ln -s /storage/docker/ docker
[root@s26 lib]# ls -la docker
lrwxrwxrwx. 1 root root 15 11月 17 13:43 docker -> /storage/docker
[root@s26 lib]# service docker start
```
### 使 swap "WARNING: Your kernel does not support cgroup swap limit. WARNING: Your kernel does not support swap limit capabilities. Limitation discarded."
swap 使
* `/etc/default/grub` Ubuntu `GRUB_CMDLINE_LINUX="cgroup_enable=memory swapaccount=1"`
* grub`$ sudo update-grub`
*
## Docker
### Docker LXCLinux Container
LXC Linux Docker
*
* AUFS 便
* Git便
*
* Docker Docker PaaSCI Docker 便
### Docker Vagrant
* Vagrant Boot2Docker Docker Vagrant WindowsMac Linux Docker
* Docker Linux
Vagrant Docker
### Docker Vagrant
Docker Linux Vagrant
使 Linux 使 Docker
使 macOS Windows Vagrant Vagrant 使 Docker
##
### Docker Linux Windows macOS
[ Docker](../../install/)
### 宿 Docker 宿
Docker Docker 宿宿
### Docker
Docker 宿 `/var/run/netns` 宿访
使 1234
```bash
$ docker inspect --format='{{. State.Pid}} ' $container_id
1234
```
`/proc` `/var/run/netns`
```bash
$ sudo ln -s /proc/1234/ns/net /var/run/netns/
```
宿
```bash
$ sudo ip netns show
1234
```
IP `172.17.0.100/16`
```bash
$ sudo ip netns exec 1234 ifconfig eth0 172.17.0.100/16
```
### veth
Docker veth veth
`ip a` `205` 1 `206` `ip a` `206` veth