背景:使用runlike
工具查看容器启动命令
pip install runlike
#安装之后有个警告
WARNING: The script runlike is installed in '/Users/admin/Library/Python/2.7/bin' which is not on PATH.
Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
执行runlike centos1
出现错误command not found: runlike
zsh: command not found: runlike
解决:
思路:执行脚本一般都在/bin
目录下,将/Users/admin/Library/Python/2.7/bin
添加到PATH
环境变量中即可。
本人环境:mac的zsh终端,而zsh终端会使用~/.bash_profile
配置,所以我们将配置加入到.bash_profile
文件中即可。
查看zsh的配置信息 cat ~/.zshrc
...
# User configuration
source ~/.bash_profile
...
修改.bash_profile
配置文件
#编辑
vim ~/.bash_profile
#添加环境变量
export PATH="/Users/admin/Library/Python/2.7/bin:$PATH"
#执行生效
source ~/.bash_profile
再次执行runlike centos1
,OK👌
docker run --name=centos1 --hostname=d09ca1a34d6a --mac-address=02:42:ac:11:00:03 --env=PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin --privileged -p 5002:22 --restart=no --label='org.label-schema.name=CentOS Base Image' --label='org.label-schema.license=GPLv2' --label='org.label-schema.vendor=CentOS' --label='org.label-schema.schema-version=1.0' --label='org.label-schema.build-date=20210915' --detach=true -t centos /usr/sbin/init