查看Docker run 参数

最近一个同事离职了,交接很简洁,其实这也是我的失职,在交接时做得不到位,未定义清交接范围,本以为只是一两个项目,谁知道,最后很多东西出问题了,大家都来找我处理问题,我才发现,事情大了。同事走得很干脆,离职后所有文档情况,电话、微信、QQ拉黑,已经人间蒸发了,那就只有自己扛着。

Python2.7.5安装PIP

其中有一个项目出问题了,我对他如何部署是一无所知,最后登录到服务器才发现,他用的Docker部署,我们一般部署都是基于K8S或者直接主机运行,他这种我还没用过,现在我要弄清楚他的docker run参数,可是一般情况下是看不见的,所以这里需要借助一款叫runlike的工具,由于我的Linux比较老,Python是2.7.5默认不带pip,那么就选哟先安装pip,其实可以将Python升级的,这里为降低风险,就尽量不升级,所以我选择了下载的方式安装

1
2
3
4
5
6
7
8
9
10
11
12
13
 wget https://bootstrap.pypa.io/pip/2.7/get-pip.py
--2021-10-15 09:54:40-- https://bootstrap.pypa.io/pip/2.7/get-pip.py
Resolving bootstrap.pypa.io (bootstrap.pypa.io)... 151.101.228.175, 2a04:4e42:1a::175
Connecting to bootstrap.pypa.io (bootstrap.pypa.io)|151.101.228.175|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 1908226 (1.8M) [text/x-python]
Saving to: ‘get-pip.py’

100%[=============================================================================================================================================>] 1,908,226 191KB/s in 10s

2021-10-15 09:54:53 (182 KB/s) - ‘get-pip.py’ saved [1908226/1908226]


然后执行python get-pip.py进行安装

1
2
3
4
5
6
7
8
9
10
python get-pip.py
DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained. pip 21.0 will drop support for Python 2.7 in January 2021. More details about Python 2 support in pip can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support pip 21.0 will remove support for this functionality.
Collecting pip<21.0
Downloading pip-20.3.4-py2.py3-none-any.whl (1.5 MB)
|████████████████████████████████| 1.5 MB 8.5 kB/s
Collecting wheel
Downloading wheel-0.37.0-py2.py3-none-any.whl (35 kB)
Installing collected packages: pip, wheel
Successfully installed pip-20.3.4 wheel-0.37.0

Ok,我们可以看到它已经提示我们安装成功,但是我们还是需要验证一下,这里执行pip -V来看看是否安装成功

1
2
pip -V
pip 20.3.4 from /usr/lib/python2.7/site-packages/pip (python 2.7)

PIP安装RunLike

接下来就用pip安装runlike

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
pip install runlike
DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained. pip 21.0 will drop support for Python 2.7 in January 2021. More details about Python 2 support in pip can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support pip 21.0 will remove support for this functionality.
Collecting runlike
Downloading runlike-0.7.0.tar.gz (7.1 kB)
Collecting Click
Downloading click-7.1.2-py2.py3-none-any.whl (82 kB)
|████████████████████████████████| 82 kB 6.8 kB/s
Building wheels for collected packages: runlike
Building wheel for runlike (setup.py) ... done
Created wheel for runlike: filename=runlike-0.7.0-py2-none-any.whl size=4375 sha256=289a5dc0e05cc920aaecdb221b5bb4a7c4e8aafd75afae2df83ec93c0e85309f
Stored in directory: /root/.cache/pip/wheels/9f/14/a5/50a3dd45b5a7b7ad90b4652d9055c0b04755fadbe619c136f3
Successfully built runlike
Installing collected packages: Click, runlike
Successfully installed Click-7.1.2 runlike-0.7.0

我来看看这个RunLike是怎么用的

1
2
3
4
5
6
7
8
9
runlike --help
Usage: runlike [OPTIONS] CONTAINER

Shows command line necessary to run copy of existing Docker container.

Options:
--no-name Do not include container name in output
-p, --pretty
--help Show this message and exit.

按照提示的意思是,直接执行runlike -p 容器Id/容器名,我们来试试看,先把运行的容器列出来docker ps

这里假设我们要运行查看这个nginx容器的启动参数

1
runlike -p testnginx

里面显示了所有的启动参数,但是我们启动的时候并没有这么多,只是配置了映射路径和端口而已,这里的runlike可以不用-p参数,如runlike testnginx只不过打印出来的内容没有换行格式化

这样一来,同事就可以走得安心了,我们以后重新发布也无须担心。

作者

eyiadmin

发布于

2021-10-15

更新于

2024-05-31

许可协议

评论