创建容器常用选项

 

[root@ol85 ~]# docker run --help

[root@ol85 ~]# docker ps

[root@ol85 ~]# docker exec -it 6e7e651ec0a2 bash

 

[root@ol85 ~]# docker run -d -e env=prod  -p 88:80 --name web -h web --restart=always  nginx

[root@ol85 ~]# docker exec -it web bash    ===》进入这个容器  容器id ,或者 容器name 都可以

检查设置是否正确

root@web:/usr/share/nginx# pwd
  /usr/share/nginx

root@web:/usr/share/nginx/html#   echo "<h1>hello word</h1>" > index.html

root@web:/# hostname
  web
root@web:/# echo $env
  prod

[root@ol85 ~]# docker exec -it web bash
root@web:/# ls /usr/share/nginx/html/
50x.html index.html

 

 ls /var/lib/docker/containers/

 

[root@ol85 ~]# docker run -it -d centos 

[root@ol85 ~]# docker ps -l

[root@ol85 ~]# docker exec -it practical_shannon bash
[root@cb636ed51f13 /]# ls
  bin etc lib lost+found mnt proc run srv tmp var
  dev home lib64 media opt root sbin sys usr

[root@ol85 ~]# docker commit practical_shannon test

[root@ol85 ~]# docker image ls

 

posted @ 2022-05-08 19:04  老王的农场  阅读(37)  评论(0编辑  收藏  举报