docker,dockerfile , docker RUN append to /etc/hosts in Dockerfile not working


docker RUN append to /etc/hosts in Dockerfile not working

Question:

Tag: docker,dockerfile

I have a simple Dockerfile but the first RUN command (to append a host IP address to /etc/hosts) has no effect

FROM dockerfile/java
RUN sudo echo "XX.XX.XXX.XXX some.box.com MyFriendlyBoxName" >> /etc/hosts
ADD ./somejavaapp.jar /tmp/
#CMD java -jar /tmp/somejavaapp.jar
EXPOSE 8280

I build using

docker build .

and then test the RUN echo line has worked using

sudo docker run -t -i <built image ID> /bin/bash

I am then into the container but the /etc/hosts file has not been appended. Running the same echo .... line while now in the container has the desired effect

Can anyone tell me what is wrong with my dockerfile RUN ...?


Answer:

Docker will generate /etc/hosts dynamically every time you create a new container. So that it can link others. You can use --add-host option:

docker run --add-host www.domain.com:8.8.8.8 ubuntu ping www.domain.com

Related:


docker run local script without host volumes


database,shell,docker,docker-compose
The goal is to add data to my database server containers of a multi-container web app from a download using curl once the database containers are running. I can do this from docker-compose.yml or from docker run independent of the web app, as long as I use host volumes. How...

PyCharm add remote Python interpreter inside the Docker


python,docker,pycharm,remote-debugging,boot2docker
So I have set up a docker on my laptop. I'm using Boot2Docker so I have one level of indirection to access the docker. In PyCharm, I can set a remote python interpreter via SSH but I'm not sure how to do it for dockers that can only be accessed...

How to properly set VOLUME and CMD instructions in Postgres Dockerfile?


postgresql,docker,dockerfile
I have a working Postgres Dockerfile that I modify and unfortunately after applying modifications Postgres container stops working as expected. I'd like to ask your for explanation of what I'm doing wrong. Working example Here's the Postgres Dockerfile that works and which I modify: # Use ubuntu image FROM ubuntu...

How to edit file after I shell to a docker container?


docker
I successfully shelled to a docker container using docker exec -i -t 69f1711a205e bash Now I need to edit file and I don't have any editors inside [email protected]:/# nano bash: nano: command not found [email protected]:/# pico bash: pico: command not found [email protected]:/# vi bash: vi: command not found [email protected]:/# vim...

What tool can manage Docker container to start in order?


docker,containers
We're trying to port our system to the containers, currently we try Docker module with Puppet and we face an issue with the order of starting some specific conainers. We have a web application, MySQL, NginX and then everything connect through HAproxy. Each of them live in their own container....

Simple docker deployment tactics


bash,docker,dockerfile
Hey guys so I've spend the past few days really digging into Docker and I've learned a ton. I'm getting to the point where I'd like to deploy to a digitalocean droplet but I'm starting to wonder about the strategy of building/deploying an image. I have a perfect Dev setup...

ctrl+G in erl doesn't work


unicode,encoding,utf-8,erlang,docker
I'm trying to interconnect erlang nodes, but entering ctrl+G doesn not work: Eshell V6.4.1 (abort with ^G) 1> ^G Eshell V6.4.1 (abort with ^G) 1> ^G Eshell V6.4.1 (abort with ^G) 1> ^G Eshell V6.4.1 (abort with ^G) any idea why this can happen? I was thinking about locale settings,...

SocketError: No such file or directory - connect(2) for /var/run/docker.sock


ruby-on-rails,docker,boot2docker
I am trying to run a docker container inside a rails application, however I keep receiving the following error:- container = Docker::Container.create({'Image' => 'mitc/judge'}) Excon::Errors::SocketError: No such file or directory - connect(2) for /var/run/docker.sock (Errno::ENOENT)` The environment variables are set bash-3.2$ env | grep DOCKER DOCKER_HOST=tcp://192.168.99.100:2376 DOCKER_TLS_VERIFY=1 DOCKER_CERT_PATH=/Users/ayushlodha/.docker/machine/machines/dev The container...

Does Google Container Registry undergo issues?


docker,google-cloud-platform,google-container-engine,google-container-registry
I am facing an issue while using container optimized VMs. I launch an instance with following command: gcloud compute instances create "$instance_name" \ --tags "http-server" \ --image container-vm \ --scopes storage-rw,logging-write \ --metadata-from-file google-container-manifest="m2.yml" \ --zone "$my_zone" \ --machine-type "$my_machine_type" where m2.yml is: version: v1beta2 containers: - name: nginx image:...

When should you create more than one docker container image instance with Kubernetes Replication Controller?


docker,google-compute-engine,kubernetes
When using Kubernetes to manage your docker containers, particularly when using the replication controller, when should you increase an images running container instances to more than 1? I understand that Kubernetes can spawn as many container replicas as needed in the replication controller configuration file, but why spawn multiple running...

Docker-compose and pdb


python,docker,pdb,docker-compose
I see that I'm not the first one to ask the question but there was no clear answer to this: How to use pdb with docker-composer in Python development? When you ask uncle Google about django docker you get awesome docker-composer examples and tutorials and I have an environment working...

Why does single-user with heredocs and multiline queries throw syntax errors for postgres+docker?


postgresql,docker
So I'm trying to create a Postgres database running on Docker. I have the following file /Users/wwerner/programming/test/dockerdb/build_db.sh: echo "************* Here comes your db! ****************" gosu postgres postgres --single <<- EOSQL CREATE SCHEMA test; CREATE TABLE test.will_fail ( id integer NOT NULL, name character varying NOT NULL); EOSQL echo "" echo...

Vagrant + puppet + docker


mysql,docker,vagrant,puppet
I'm new with this technologies but I want to learn about automation and containers stuff. I read some documentation about this 3 products and I want to know if is possible to automate almost everything in a large environment using this products. Vagrant for deploy VMs (let's say 10 at...

Best practice for docker webserver, muliple layers or single layer?


webserver,docker
I want to build a docker webserver, serving Nginx, PHP and MySQL for multiple websites. Would it be better to run a single docker container for each component, ie one for MySQL, one for Nginx, One for PHP and another for my site data. Or Run multipul containers that each...

Docker container http requests limit


http,elasticsearch,docker
I'm new to Docker so, most likely, I'm missing something. I'm running a container with Elasticsearch, using this image. I'm able to setup everyhing correctly. After that I was a using a script developed by a collegue in order to insert some data, basically querying a MySQL database and making...

docker set iptables options in docker-compose.yml


docker
I'm using docker-compose for managing containers. How to I turn off iptables (set --iptables=false for docker) when starting via docker-compose up?...

Server and client network apps simulated in one machine


docker,systemd
I would like to simulate a server machine and several client machines operating over a vpn. I would like to test the server application as well as the client applications all on one machine. Would I be able to do this with a few docker applications running on my machine...

Meteor mupx ssl configuration is not working, still routing to port 80


javascript,ssl,meteor,docker
Heres my mup.json: // Configure environment "env": { "PORT": 3000, "ROOT_URL": "https://www.exomatch.com" }, //SSL "ssl": { "certificate": "ssl/ssl.crt", // this is a bundle of certificates "key": "ssl/private.key", // this is the private key of the certificate "port": 443 // 443 is the default value and it's the standard HTTPS port...

Golang failes to change the name of imported module


go,docker,skydns
I'm trying to bring SkyDNSv1 back to life and build it from my fork (here is Dockerfile). SkyDNS was really good and simple tool for the quick service discovery, but it wasn't updated for a long time. There is an error in build process and it's caused by third party...

Access binaries inside docker


ubuntu,meteor,docker
I am using Meteor and Meteur Up package to push a bundle to server. It uses docker. The problem is that I cannot access graphicsmagick or imagemagick from inside a docker to use it in my app. However it is installed on the server and I can access it when...

Passing Elasticsearch and Kibana config file to docker containers


elasticsearch,docker,kibana,kibana-4
I have found a docker image devdb/kibana which runs Elasticsearch 1.5.2 and Kibana 4.0.2. However I would like to pass into this docker container the configuration files for both Elasticsearch (i.e elasticsearch.yml) and Kibana (i.e config.js) Can I do that with this image itself? Or for that would I have...

Installing Python 3 Docker Ubuntu error command 'x86_64-linux-gnu-gcc


python,python-3.x,amazon-web-services,docker
I'm trying to create a dockerfile that uses Python 3. FROM ubuntu:14.04 RUN apt-get update RUN apt-get install -y python3 python3-dev python-pip RUN apt-get install -y libxml2-dev libxslt1-dev libpq-dev libjpeg-dev libfreetype6-dev zlib1g-dev RUN cd /var/projects/apps && pip install -r requirements.txt I get the error fatal error: Python.h: No such file...

How to see a linked container as localhost?


docker,docker-compose
I have this two containers : api: image: social-learning ports: - "3000:3000" command: bundle exec rails s -p 3000 -b '0.0.0.0' volumes: - ../api:/app expose: - "3000" web: image: social-learning-frontend ports: - "4200:4200" - "9000:9000" command: ember serve -p 4200 volumes: - .:/app links: - api expose: - "3000" When...

Why are images created and why doesn't Docker clean them up?


docker
I know how to removed containers and images. What I don't understand is why those <none> images are created in the process of a docker build -t my_container . or a similar command. Running docker images will give me something like that: REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE go_dev...

Use of container docker as a proxy for CF app to get public IP


docker,containers,bluemix
I need a public IP for my application: is it a proper solution to use docker container as a proxy? I can see the price increasing quite a lot with all traffic going through proxy to reach the application. Is there any other option recommended?

autoexpect on docker centos6.6 container cannot work


centos,docker,expect,autoexpect
Docker container pure image: centos6.6 after bash, I install these: yum -y install tar zip unzip expect glibc.i686 Package expect-5.44.1.15-5.el6_4.x86_64 already installed and latest version and run autoexpect, I always get these error: [[email protected] bin]# autoexpect autoexpect started, file is script.exp no such variable (read trace on "env(SHELL)") invoked from...

Saving docker container image


jenkins,docker
I created a new docker container using jenkings image This is the command I ran docker run -p 8080:8080 -v /var/jenkins_home jenkins I created a few jobs on the jenkins instance and commited the image docker commit 7b903d061654 test When I run the image I created using the command (below)...

How to customize the configuration file of the official PostgreSQL docker image?


postgresql,docker
I'm using the the postgres official image https://registry.hub.docker.com/_/postgres/. And now I'm trying to customize its configuration. For this purpose the command sed is used, e.g. to change the max_connections: sed -i -e"s/^max_connections = 100.*$/max_connections = 1000/" /var/lib/postgresql/data/postgresql.conf I tried two methods to apply this configuration. The first is by adding...

Not able to access Kibana running in a Docker container on port 5601


elasticsearch,docker,dockerfile,kibana-4
I have built a docker image with the following Docker file. # gunicorn-flask FROM devdb/kibana MAINTAINER John Doe <[email protected]> ENV DEBIAN_FRONTEND noninteractive RUN apt-get update RUN apt-get install -y python python-pip python-virtualenv gunicorn # Setup flask application RUN mkdir -p /deploy/app COPY gunicorn_config.py /deploy/gunicorn_config.py COPY app /deploy/app RUN pip install...

Docker Compose with one Terminating Container


docker,exit,exit-code,docker-compose,fig
I'm having a docker compose setup of a database container, an application container and one container which pre-loads the database with necessary data. I want to start all of the containers together with docker-compose up while the pre-loading container terminates after it is one with exit 0. But terminating this...

How to mount volume for docker container via yaml manifest?


docker,google-cloud-platform,google-container-engine
I try to launch container-vm machine with following yaml: version: v1 kind: Pod spec: containers: - name: simple-echo image: gcr.io/google_containers/busybox command: ['nc', '-p', '8080', '-l', '-l', '-e', 'echo', 'hello world!'] imagePullPolicy: Always ports: - containerPort: 8080 hostPort: 8080 protocol: TCP volumeMounts: - name: string mountPath: /home readOnly: false restartPolicy: Always...

My docker container was created with no name and no tag


docker,boot2docker
I'm creating a docker image for hakyll compilation. Here's the dockerfile: FROM haskell:7.10 RUN cabal update && cabal install hakyll This file is in some folder on my D: drive: D:\Haskell\docker\docker-hakyll. I'm using Boot2Docker on Windows to build it. docker images gives me REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE...

Where does kubernete's kubelet create service environment variables?


node.js,docker,service-discovery,kubernetes
I'm creating a kubernetes cluster, and in it I have several services. I know based on https://github.com/GoogleCloudPlatform/kubernetes/blob/master/docs/services.md#discovering-services I have two options. use the environment variables set by the kubelet. use skydns I want to try to use the environment variables first before I go adding another dependency into the mix....

What's the best way to share files from Windows to Boot2docker VM


docker,boot2docker
I have make my code ready on Windows, but I find it's not easy to share to boot2docker. I also find that boot2docker can't persistent my changes. For example, I create a folder /temp, after I restart boot2docker, this folder disappears, it's very inconvenient. What is your way when you...

Any suggestion for running Aerospike on Kubernetes on CoreOS on GCE?


docker,google-compute-engine,kubernetes,aerospike
I would like to run Aerospike cluster on Docker containers managed by Kubernetes on CoreOS on Google Compute Engine (GCE). But since GCE does not permit multicast, I have to use Mesh heartbeat as described here, which has to be set up by specifying all node's IP addresses and ports;...

difference between docker attach and docker exec


docker,exec
Both will be able to execute commands in container. Both could detach the container. So what is the real difference between docker exec and docker attach?...

What is the '.save_docker/' folder? Can I delete it?


linux,docker
After using docker, I found my disk space had been eat a lot. I searched google to resolve the problem, found a post said this is because of aufs & devicemapper. Now I found a folder named .save_docker in /home. In this folder, there is a folder names aufs, the...

Docker inspect with unix:///var/run/docker.sock (in Java or Scala)


java,scala,docker
Docker has lots of interesting information available via unix:///var/run/docker.sock I have been able to map this to a port and I can access /containers/json with GET requests to the port. But... this is not exactly secure. How can I access /containers/json from this raw socket file (in Java or Scala)?...

Run Boot2Docker from bash


osx,bash,docker,boot2docker
I have installed Boot2Docker on my Mac. By clicking on the app icon, a terminal window opens with some bash script running to prepare the docker vm and then you're good to go. My problem is, I want to write a bash script to run the Boot2Docker vm and then...

Why is /etc/hosts file empty in my docker container?


docker
I created a minimal docker container, following https://github.com/snoyberg/haskell-scratch containing a single Haskell application. When run the application works fine except it cannot resolve hosts from /etc/hosts because it is empty which implies linking does not work correctly (or at least I need to use numeric addresses which is impractical...). I...

ERROR: (gcloud.preview) Invalid choice: 'docker'. Did you mean 'dm-v2'?


docker,google-cloud-platform,gcloud
Somehow I was able to push my docker image to Google Container Registry with command: $ gcloud preview docker push gcr.io/<my-project-xxx>/<my-image-yyy> I ran the commands yesterday and copied them to my notes, but today pasting them to terminal in the same order I get the error: ERROR: (gcloud.preview) Invalid choice:...

Configure Dockerfile to set AWS configurations


node.js,amazon-web-services,docker
I've just started looking at Docker. I have a node app that resizes and image and then sends an SQS message to aws when finished. I have managed to create a docker image of my app, copying it from my local machine, but run into the issue that I can't...

Unable to get docker containers running disque to establish a cluster


docker,disque
I put together a docker container building disque https://registry.hub.docker.com/u/jobflow/disque/ I am able to deploy and run a single service. I can expose a port and connect to it from a disque client running on the same container or a different container. But when connect to one instance and send the...

Ensure nginx master process stays running


nginx,docker,supervisord
I am currently trying to setup a docker container using ubuntu:14.04 as my base image, with nginx and gunicorn/django/celery running inside. I am using supervisor to start all of the processes, and have tested to make sure gunicorn is relaunched when it goes down. However, I can't figure out how...

Is there a way to tell kubernetes to update your containers?


automation,docker,kubernetes
I have a kubernetes cluster, and I am wondering how (best practice) to update containers. I know the idea is to tear down the old containers and put up new ones, but is there a one-liner I can use, do I have to remove the replication controller or pod(s) and...

docker is using the v1 registry api when it should use v2


docker,coreos,docker-registry
I'm trying to use a self hosted docker registry v2. I should be able to push a docker image, which does work locally on the host server (coreos) running the registry v2 container. However, on a separate machine (also coreos, same version) when I try to push to the registry,...

docker run python from container


docker
I took over a project which requires the usage of docker to setup the development environment. The project wiki is primarily written for use with coreos and one of the setup steps involved running a python script. I'm using boot2docker and realised that there's no python pre-installed with the tcl....

How do I turn sendfile off in a docker instance


linux,nginx,configuration,docker,sendfile
I have a nginx docker instance running. In the docker instance there is a file called /etc/nginx/nginx.conf It has the following settings http { include /etc/nginx/mime.types; default_type application/octet-stream; log_format main '$remote_addr - $remote_user [$time_local] "$request" access_log /var/log/nginx/access.log main; sendfile on; .... } I run the docker instance by running with...