Docker Community Forums

Share and learn in the Docker community.

Need to connect to host IP during build process


(Timothy Harris) #1

Hi All,

I have the following scenario. I have a service running on my host. I am building a container that is downloading a JAR file from this service when building an image. How do I connect to this service when building an image?

FROM openjdk:8-windowsservercore

SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]

ENV TOOLS_DIR "C:\tools"
ENV VERSION  6.2.1
ENV BAMBOO_AGENT  bamboo-agent-${VERSION}.jar
ENV BAMBOO_AGENT_INSTALL ${TOOLS_DIR}/bamboo-agent-${VERSION}
ENV BAMBOO_AGENT_HOME "C:\bamboo-agent-home"


# Where to get the binary
ENV REPOSITORY_HOST http://10.100.1.244:8081/artifactory
ENV REPOSITORY example-repo-local/atlassian/bamboo-agent
ENV BAMBOO_AGENT_DOWNLOAD_URL ${REPOSITORY_HOST}/${REPOSITORY}/${VERSION}/${BAMBOO_AGENT}

# Where to store stuff TODO check that we don't overwrite
RUN mkdir $env:TOOLS_DIR; \
    mkdir $env:BAMBOO_AGENT_INSTALL; \
    mkdir $env:BAMBOO_AGENT_HOME

# Todo why can't I use expanded env vars?
WORKDIR BAMBOO_AGENT_INSTALL

RUN Write-Host ('Downloading {0} ...' -f $env:BAMBOO_AGENT_DOWNLOAD_URL)
RUN wget -Uri $env:BAMBOO_AGENT_DOWNLOAD_URL -OutFile $env:BAMBOO_AGENT

EXPOSE 8080
EXPOSE 54663

I tried using the --add-host=myhost:10.100.1.244 --no-cache when building the image but it doesn’t seem to work :frowning:

wget : The operation has timed out.
At line:1 char:76
+ ... yContinue'; wget -Uri $env:BAMBOO_AGENT_DOWNLOAD_URL -OutFile $env:BA ..
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (System.Net.HttpWebRequest:Htt
   pWebRequest) [Invoke-WebRequest], WebException
    + FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShe
   ll.Commands.InvokeWebRequestCommand

(Timothy Harris) #2

An Update.

Removed the RUN for download. Built the container. Exec’d into the container. Ran the command from powershell within the container. It timed out :astonished: ! What in the ever loving…

Tried a smaller download and it went fine. What is going on here…