Dockerfile HOSTNAME Instruction for docker build like docker run -h

后端 未结 3 2048
故里飘歌
故里飘歌 2021-01-02 16:39

I am attempting to set the hostname inside a docker container during the build since certain software installs use the discovered randomly generated hostname and permanently

3条回答
  •  孤独总比滥情好
    2021-01-02 17:28

    You can use docker-compose to build your image and assign the hostname, e.g.

    version: '3'
    services:
      all:
        image: testimage
        container_name: myname
        hostname: myhost
        build:
          context: .
    

    The run as: docker-compose --build up.

提交回复
热议问题