--name 名称 -it -i 容器输入终端保持打开, -t开一个伪终端
ip ad li 查看网段
docker attach id 获取docker
有些容器进入不成功
后台运行 ctrl p + ctrl q
获取容器pid
nsenter
nsenter --target 4497 --mount --uts --ipc --net --pid
root /usr/share/nginx/html
91 映像端口 80 容器被映像的端口
-h 指定主机名 -v 数据卷
docker run -it --name volume-test1 -h centos -v /datacentos
docker inspect -f "{{.Volumes}}"volume-test1
docker日志如何存储
只读格式
useradd -s /sbin/nologin -M www
前台运行
docker commit -m "my nginx" c85374823499rainyday/my-ngnix:v1
#This is My first Dockerfile
# Version 1.0
#Author : Rainyday
From centos
#MAINTAINER
MAINTAINER Rainyday
#ADD
ADD pcre-8.42.tar.gz /usr/local/src
ADD nginx-1.13.12.tar.gz /usr/local/src
#RUN
RUN yum install -y wget gcc gcc-c++ make openssl-devel
RUN useradd -s /sbin/nologin -M www
#WORKDIR
WORKDIR /usr/local/src/nginx-1.13.12
RUN ./configure --prefix=/usr/local/nginx --user=www--with-http_ssl_module --with-http_stub_status_module--with-pcre=/usr/local/src/pcre-8.42 && make &&make install
RUN echo "daemon off;" >>/usr/local/nginx/conf/nginx.conf
ENV PATH /usr/local/nginx/sbin:$PATH
EXPOSE 80
CMD ["nginx"]
资源限制 cgroup
http://mirrors.aliyun.com/repo/
wget http://mirrors.aliyun.com/repo/epel-6.repo
docker build -t stress .
docker images
docker run -it --rm -c 512 stress --cpu 1 指定cpu大小
docker run -it --rm stress --cpu 1 指定cpu
docker run -it --rm --cpuset-cpus=0 stress --cpu 1
指定占用几个cpu
docker exec id
docker run -it --rm -m 128m stress --v
m 1 --vm-bytes 120m --vm-hang 0
测压大于两倍关掉
cpu -c --cpu-set
内存 -m
docker 网络模式
docker run -d -p 5001:5000 registry
docker push localhost:5001/test/e:v1
docker tag d1fd7d86a825 47.106.154.105:5001/test/es:v1
echo '{"insecure-registries":["47.106.154.105:5001"] }' >/etc/docker/daemon.json
docker pull 47.106.154.105:5001/test/e:v1
shipyard
-H tcp:0.0.0.0:235 -H unix:///var:/run/docker.sock
docker run -it -d --name shipyard-rethinkdb-data--entrypoint /bin/bash shipyard/rethinkdb -l