docker-build

Docker container doesn't expose ports when --net=host is mentioned in the docker run command

流过昼夜 提交于 2019-12-18 03:01:57
问题 I have a CentOS docker container on a CentOS docker host. When I use this command to run the docker image docker run -d --net=host -p 8777:8777 ceilometer:1.x the docker container get host's IP but doesn't have ports assigned to it. If I run the same command without "--net=host" docker run -d -p 8777:8777 ceilometer:1.x docker exposes the ports but with a different IP. The docker version is 1.10.1. I want the docker container to have the same IP as the host with ports exposed. I also have

Docker build is not stopping on failed run command

十年热恋 提交于 2019-12-11 17:57:22
问题 I have this in a Dockerfile RUN eval `ssh-agent -s` && ssh-add /root/.ssh/id_rsa and I see: The command '/bin/sh -c eval ssh-agent -s && ssh-add /root/.ssh/id_rsa' returned a non-zero code: 1 but the docker build continues until it reaches the ENTRYPOINT and then exits. How can I get the docker build process to stop if one of the RUN commands exits with non-zero? 回答1: Docker don't connect the different parts of your run command as an logical AND . It is more like a OR Do this: RUN eval `ssh

Docker build tag repository name

守給你的承諾、 提交于 2019-12-05 22:44:00
问题 One can easily build docker images through docker build command. What I'm wondering is the t flag that you can give when building the image. For example: $ docker build -t ouruser/sinatra:v2 . According to documentation, the t flag is for tagging and naming purposes. Name is the part before ':', and tag is the part after it. So in our example, the name is ouruser/sinatra, and the tag is v2. I thought this would be the image name and tag. But apparently, the name is actually some repository

Is it possible to set a MAC address for `docker build`?

十年热恋 提交于 2019-12-04 06:06:32
With docker run , it’s possible to fix the MAC address with the --mac-address option. I’ve looked, and I can’t find a way to fix the MAC address with docker build . I am wanting to dockerize software that has a license fixed to a MAC address (I’m not trying to get around the license; I’m trying to have a more reproducible system architecture). Thanks! Let's consider the below Dockerfile FROM alpine RUN ifconfig | grep -i hwaddr If you build it using docker build . You get Sending build context to Docker daemon 2.048kB Step 1/2 : FROM alpine ---> 7328f6f8b418 Step 2/2 : RUN ifconfig | grep -i

Docker build tag repository name

大憨熊 提交于 2019-12-04 04:28:55
One can easily build docker images through docker build command. What I'm wondering is the t flag that you can give when building the image. For example: $ docker build -t ouruser/sinatra:v2 . According to documentation, the t flag is for tagging and naming purposes. Name is the part before ':', and tag is the part after it. So in our example, the name is ouruser/sinatra, and the tag is v2. I thought this would be the image name and tag. But apparently, the name is actually some repository name? Why do I think it is? Well, because if you would after this list the images with command: docker

Why can't I use the build arg again after FROM in a Dockerfile?

放肆的年华 提交于 2019-12-01 08:18:13
I'm using Docker 18.05.0~ce~3-0~ubuntu and I'd like to pass a build argument to the FROM as well as other lines in my Dockerfile. You would expect the below to work: ARG FROM_IMAGE=ubuntu:bionic FROM $FROM_IMAGE COPY sources_list/$FROM_IMAGE /etc/apt/sources.list It works for the second line ( FROM ), but it behaves like it is unset in the COPY line: Step 1/3 : ARG FROM_IMAGE=ubuntu:bionic Step 2/3 : FROM $FROM_IMAGE ---> 8626492fecd3 [...] Step 3/3 : COPY sources_list/${SOURCES_LIST_FILE} /etc/apt/sources.list failed to copy files: failed to copy directory: mkdir /var/lib/docker/overlay2

Why can't I use the build arg again after FROM in a Dockerfile?

旧时模样 提交于 2019-12-01 06:59:51
问题 I'm using Docker 18.05.0~ce~3-0~ubuntu and I'd like to pass a build argument to the FROM as well as other lines in my Dockerfile. You would expect the below to work: ARG FROM_IMAGE=ubuntu:bionic FROM $FROM_IMAGE COPY sources_list/$FROM_IMAGE /etc/apt/sources.list It works for the second line ( FROM ), but it behaves like it is unset in the COPY line: Step 1/3 : ARG FROM_IMAGE=ubuntu:bionic Step 2/3 : FROM $FROM_IMAGE ---> 8626492fecd3 [...] Step 3/3 : COPY sources_list/${SOURCES_LIST_FILE}

How do I copy variables between stages of multi stage Docker build?

故事扮演 提交于 2019-11-29 20:02:23
问题 I've only seen examples of using COPY to copy files between stages of a multi stage Dockerfile, but is there a way to simply copy an ENV variable? My use case is to start out with a git image to just to get the commit hash that will be part of the build. The image I'm later building with hasn't got git. I realise I could just pipe out the git hash to a file and use COPY but I'm just wondering if there's a cleaner way? 回答1: You got 3 options: The "ARG" solution, the "base" solution, and "file"

How to Specify $docker build --network=“host” mode in docker-compose at the time of build

淺唱寂寞╮ 提交于 2019-11-29 18:28:21
问题 While building docker image like docker build -t name:tag --network="host" so it will Set the networking mode for the RUN instructions during build (default "default") So I am trying to build Docker image with DOKCER-COMPOSE: version: '3' services: ezmove-2.0: network_mode: "host" build: context: . ports: - "5000:5000" So as per above compose file I am trying to build image but how to Specify --network="host" mode in docker-compose at the time of build 回答1: @dkanejs is right, and here is how

Docker container doesn't expose ports when --net=host is mentioned in the docker run command

独自空忆成欢 提交于 2019-11-29 05:27:41
I have a CentOS docker container on a CentOS docker host. When I use this command to run the docker image docker run -d --net=host -p 8777:8777 ceilometer:1.x the docker container get host's IP but doesn't have ports assigned to it. If I run the same command without "--net=host" docker run -d -p 8777:8777 ceilometer:1.x docker exposes the ports but with a different IP. The docker version is 1.10.1. I want the docker container to have the same IP as the host with ports exposed. I also have mentioned in the Dockerfile the instruction EXPOSE 8777 but with no use when "--net=host" is mentioned in