docker
2022-01-06 17:23:41 0 举报
AI智能生成
sss
作者其他创作
大纲/内容
dockerfile
FROM
作为基础镜像进行构建
RUN
CMD
用于运行程序
docker build
docker build -t centos-httpd:v2 .
docker images # 查看是否成功
配置tomcat
vim dockerfile
docker build -t tomcat8:v1 .
docker run --name tomcat -p 8080:8080
安装
yum install -y yum-utils \
device-mapper-persistent-data \
lvm2
device-mapper-persistent-data \
lvm2
yum-config-manager \
--add-repo \
http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
--add-repo \
http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
yum install docker-ce docker-ce-cli containerd.io
镜像
镜像操作
查看镜像
docker images
docker run --name test --rm -d -it centos:7
docker image ls
获取镜像
docker search CentOS
docker pull centos:7 # 如果不接版本号,会使用最新版本的镜像 latest版本
docker pull hello-world
docker pull centos:7 # 如果不接版本号,会使用最新版本的镜像 latest版本
docker pull hello-world
打标签
docker tag centos:7 abc:v1
查看镜像信息
docker inspect abc:v1
查看镜像历史
docker history abc:v1
删除镜像
docker rmi
镜像的导出与导入
docker save -o centos-httpd:v2.tar centos-httpd:v2
容器
创造容器
docker run --name test --rm -d -it centos:7
查看输出
docker logs -f -t d422c1c34f60
删除
docker rm xxx -f
导入导出
docker export -o up_test.tar 4724c04cc852
docker export 4724c04cc852 > up_test.tar
查看信息
docker inspect 4724c04cc852 -f {{".NetworkSettings"."IPAddress"}}
配置nginx
vimdockerfile
修改/etc/nginx/conf.d/*.conf文件
upstream tomcat {
server 192.168.31.128:8081; location / {
proxy_pass http://tomcat;
}
server 192.168.31.128:8081; location / {
proxy_pass http://tomcat;
}
docker build -t nginx:v1 .
docker run -d -p 8083:80 --name nginx-web nginx:v3
收藏
0 条评论
下一页