2016-02-09 31 views
5

ho questo Dockerfile:Docker: NPM installare dietro delega

FROM node:argon 

ENV http_proxy http://user:[email protected]:3128 
ENV https_proxy https://user:[email protected]:3128 

RUN mkdir -p /usr/src/app 
WORKDIR /usr/src/app 

# Install app dependencies 
COPY package.json /usr/src/app/ 
RUN npm install 

# Bundle app source 
COPY . /usr/src/app 

EXPOSE 8080 
CMD [ "npm", "start" ] 

ma ottengo questo errore, in NPM installare passo:

npm info it worked if it ends with ok npm info using [email protected] npm info using [email protected] npm WARN package.json [email protected] No description npm WARN package.json [email protected] No repository field. npm WARN package.json [email protected] No README data npm info preinstall [email protected] npm info attempt registry request try #1 at 7:09:23 AM npm http request GET https://registry.npmjs.org/body-parser npm info attempt registry request try #1 at 7:09:23 AM npm http request GET https://registry.npmjs.org/express npm info retry will retry, error on last attempt: Error: tunneling socket could not be established, cause=write EPROTO npm info retry will retry, error on last attempt: Error: tunneling socket could not be established, cause=write EPROTO

Credo che sia dovuto al proxy. Ho anche provato a inserire

RUN npm config set proxy http://user:[email protected]:3128 
RUN npm config set https-proxy http://user:[email protected]:3128 

ma continuando a ottenere lo stesso errore.

Inoltre, nel mio file /etc/systemd/system/docker.service.d/http-proxy.conf ho questo:

Environment="HTTP_PROXY=http://user:[email protected]:3128" 
Environment="HTTPS_PROXY=https://user:[email protected]:3128" 

Grazie in anticipo.

risposta

3

Prima il https_proxy deve utilizzare un URL http, non un URL https.

In secondo luogo, non è necessario incorporare le impostazioni proxy nel vostro Dockfile: è possibile utilizzare build time variables

docker build --build-arg HTTP_PROXY=http://user:[email protected]:3128 --build-arg HTTPS_PROXY=http://user:[email protected]:3128 .

Infine, proxy settings at the docker service level permette il demone finestra mobile per tirare le immagini da internet. Ciò non significa che il comando unix eseguito (direttiva RUN) da docker build ne trarrebbe vantaggio. Da qui la necessità di passarli come variabili di ambiente build-time.

3

Avevo anche lo stesso problema e non volevo impostare alcuna informazione proxy nella mia immagine in quanto non volevo dipendere dal mio ambiente aziendale.

La mia soluzione era usare un cntlm in esecuzione in modalità gateway. Per farlo ho messo il flag impostato Gateway-yes i seguenti permettono regole nella mia cntlm file di configurazione:

Gateway   yes 
# Allow local 
Allow   127.0.0.1 
# Allow docker subnetwork 
Allow   172.17.0.0/16 

Poi sono stato in grado di eseguire il mio file finestra mobile da ottenere l'indirizzo dell'interfaccia dokcer0 (ottenuto con ifconfig comando):

docker build -t my-image --build-arg HTTP_PROXY=http://172.17.0.1:3128 --build-arg HTTPS_PROXY=http://172.17.0.1:3128 . 
+0

Ho lo stesso problema ma la soluzione non funziona per me. Ho cntlm in esecuzione con successo con Firefox, l'impostazione del proxy su 127.0.0.1:3128. Ma non importa quello che provo come IP con docker non funziona. Sto usando Windows 10. Ho 10.0.75.0 come indirizzo di sottorete e per ipconfig/tutto quello che ho 10.0.75.1. NPM non installerà nulla. Qualche idea? BTW: Se inserisco informazioni utente proxy: [email protected] funziona bene. –

Problemi correlati