Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

请问为什么用Entrypoint而不用CMD呢? #27

Closed
jonozw opened this issue Jan 11, 2023 · 6 comments
Closed

请问为什么用Entrypoint而不用CMD呢? #27

jonozw opened this issue Jan 11, 2023 · 6 comments

Comments

@jonozw
Copy link

jonozw commented Jan 11, 2023

我想用 --config_dir 这样启动, 但是没有CMD搞不定

可能是我Docker不熟悉...

@snowdream
Copy link
Collaborator

可以把配置文件挂载到容器内部。

@jonozw
Copy link
Author

jonozw commented Jan 13, 2023

比方说xray的docker, 用的是
CMD [ "/usr/bin/xray", "-config", "/etc/xray/config.json" ]
这样如果我希望修改命令行, 我可以在最后用自行定义的命令行

docker run -itd --restart always --network host --hostname xray --name xray.1.7.2 --volume /opt/volumes/xray:/etc/xray teddysun/xray:1.7.2 /usr/bin/xray -confdir /etc/xray/conf.d

来覆盖原有CMD, 执行自定义的命令

但是现在frpc用的是Entrypoint
ENTRYPOINT /usr/bin/frpc -c /etc/frp/frpc.ini

没法用自定义命令来更改, 请问用Entrypoint而不用CMD的用意是什么啊?
Docker不太熟悉, 也许问题太小白了, 见谅.

@snowdream
Copy link
Collaborator

  1. frp 的配置主要在配置文件中。
  2. 你可以尝试在 docker run 命令后加上你需要的参数尝试。
  3. 更多自定义需求,可以修改自己的 Dockerfile,创建自己的docker 镜像。

@jonozw
Copy link
Author

jonozw commented Jan 16, 2023

嗯嗯, 不行就自己修改Dockerfile了, 谢谢

@jonozw
Copy link
Author

jonozw commented Jan 16, 2023

研究了一下 Entrypoint和CMD

The ENTRYPOINT gives a container its default nature or behavior, so that when you set an ENTRYPOINT you can run the container as if it were that binary, complete with default options, and you can pass in more options via the COMMAND.

所以, 我个人觉得写成这样可能更符合Docker的文档

default nature or behavior

ENTRYPOINT /usr/bin/frpc

default options

CMD [ "-c", "/etc/frp/frpc.ini" ]

@jonozw
Copy link
Author

jonozw commented Jan 16, 2023

搞定了, 还是Docker不熟悉, 搞清楚了Entrypoint和CMD的关系, 就行了

docker run -itd --restart always --network host --hostname frpc --name frpc --volume /opt/volumes/frp:/etc/frp
--entrypoint=/usr/bin/frpc
snowdreamtech/frpc:0.46.0
--config_dir /etc/frp/client-config

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants