Home  >  Q&A  >  body text

docker网络端口映射,没有方便点的操作方法么?

在容器里安装新软件后,必须commit后,再run来添加端口么,这要麻烦死了啊:(

PHP中文网PHP中文网2706 days ago629

reply all(3)I'll reply

  • 伊谢尔伦

    伊谢尔伦2017-04-25 09:06:19

    If it is still troublesome to use -p to map the port when running, you can write it in the Dockerfile

    reply
    0
  • 巴扎黑

    巴扎黑2017-04-25 09:06:19

    You can write the run command as a shell file, and then execute this file directly. No need to write every time.

    reply
    0
  • 習慣沉默

    習慣沉默2017-04-25 09:06:19

    Maybe your usage is not very correct

    Generally speaking, a container should only run one service. In this case, it seems strange to install new software into a container and then commit it

    You can create a base image, and everything else is built on this base image

    Then, docker-compose and dockerfile essentially allow you to easily manage containers and images (multiple builds of the same dockerfile will be cached as images), so you can write more on your basic image dockerfile, each dockerfile only installs one service you need to use

    The screenshot is my docker-compose.yml. When running, it is very clear that there is one service and one container

    reply
    0
  • Cancelreply