网站首页 > 技术教程 正文
前言
最近在工作中,接手了不少历史遗留的项目,有一些依赖是使用的docker启动,可以正常使用。但是由于优化服务器资源的缘故,需要将这些依赖迁移到其他服务器,这时候问题出现了。此类依赖都是直接使用docker run启动一个容器运行,没有使用docker-compose这样的编排工具,也没有保存docker run的命令,给迁移造成了麻烦。如果我们无法找到docker run的启动参数,那么迁移完成后,有大概率会出现不一致的情况。
那么,能不能找回之前的run命令呢,答案是可以的。
方法很多,笔者一般使用的是runlike命令来查看。
安装pip
# yum install -y python-pip
安装runlike
# pip install runlike
命令安装完成,下面来看一下如何通过runlike命令来找回docker run的启动参数。
发布一个测试容器
# docker run -d -v /data/nginx:/data/nginx -v /etc/hosts:/etc/hosts -p 8080:80 --name nginx nginx:1.18
# netstat -lntup | grep 8080
tcp6 0 0 :::8080 :::* LISTEN 5357/docker-proxy
# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
76a49h8f017c nginx:1.18 "nginx -g 'daemon of…" 2 seconds ago Up 2 seconds 0.0.0.0:8080->80/tcp nginx
使用runlike查看启动参数
格式:runlike -p <容器名>|<容器ID>
# runlike -p nginx
docker run \
--name=nginx \
--hostname=76a49h8f017c \
--env=PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin \
--env=NGINX_VERSION=1.18.3 \
--env=NJS_VERSION=0.3.9 \
--env='PKG_RELEASE=1~buster' \
--volume=/data/nginx:/data/nginx \
--volume=/etc/hosts:/etc/hosts \
-p 8080:80 \
--restart=no \
--label maintainer="NGINX Docker Maintainers <docker-maint@nginx.com>" \
--detach=true \
nginx:1.18 \
nginx -g 'daemon off;'
至此,再也不用担心找不到docker run参数了。
后记
工作中经常遇到此类需求,顺便记录下,供之后翻阅,养成好习惯^_^
猜你喜欢
- 2024-10-16 LNMP环境搭建-nginx(lnmp搭建后怎么做网站)
- 2024-10-16 进阶必备 | Linux系统管理工具 supervisor 详解,代码齐全可复制
- 2024-10-16 K8S 之 Ingress-nginx 源码解析(k8s nginx配置)
- 2024-10-16 编排系统K8S Ingress-nginx源码解析
- 2024-10-16 让博客Docker化,轻松上手Docker(博客登录界面)
- 2024-10-16 「这些都不知道你就是个弟弟」Docker常用命令
- 2024-10-16 容器技术:Podman 与 RESTful 接口
- 2024-10-16 Docker:网络模式详解(docker五种网络模式)
- 2024-10-16 k8s日志收集 多pod挂载不同目录方案
- 2024-10-16 Docker部署前端Web项目(docker部署webdav)
你 发表评论:
欢迎- 最近发表
- 标签列表
-
- 下划线是什么 (87)
- 精美网站 (58)
- qq登录界面 (90)
- nginx 命令 (82)
- nginx .http (73)
- nginx lua (70)
- nginx 重定向 (68)
- Nginx超时 (65)
- nginx 监控 (57)
- odbc (59)
- rar密码破解工具 (62)
- annotation (71)
- 红黑树 (57)
- 智力题 (62)
- php空间申请 (61)
- 按键精灵 注册码 (69)
- 软件测试报告 (59)
- ntcreatefile (64)
- 闪动文字 (56)
- guid (66)
- abap (63)
- mpeg 2 (65)
- column (63)
- dreamweaver教程 (57)
- excel行列转换 (56)
本文暂时没有评论,来添加一个吧(●'◡'●)