Home  >  Q&A  >  body text

Docker -p的问题

1: docker run -d -p 3000:3000 images
这里若在container内开启localhost:3000的服务,怎么才能从外部访问呢?浏览器地址是什么?

2:我commit了一个已经部署好环境的image,当下次我根据image run一个container,为什么一些shell还需要source才能生效,之前已经source过了。
web服务也需要重新开启。
不是使用Dockerfile生成的image.

3:根据Dockerfile build成的image,是不是在run时会执行内部的ENTRYPOINT,所以一些服务不需要重新开启。

谢谢!!

怪我咯怪我咯2755 days ago874

reply all(3)I'll reply

  • 天蓬老师

    天蓬老师2017-04-27 09:03:48

    Question 2:
    You should just put the operation in the script that is executed when running. The source seems to have to be executed every time it is started. In Linux, files in some locations will be automatically sourced

    Question 3:
    ENTRYPOINT is executed when the container starts, regardless of whether there is a CMD command. Services and other things are generally started in this script.

    reply
    0
  • 我想大声告诉你

    我想大声告诉你2017-04-27 09:03:48

    1. The browser address is 127.0.0.1:3000

    2. The source command is a one-time import. It will be removed from the environment variables when you exit the terminal. Next time you start the terminal, re-import it

    3. You can specify any shell command or script for the RUN command of Dockerfile

    reply
    0
  • 某草草

    某草草2017-04-27 09:03:48

    Question 1:
    container内需要 listening 0.0.0.0:3000 而不是127.0.0.1:3000

    reply
    0
  • Cancelreply