Tag: bash

How would I pass environment into docker using bash?

The following works fine in docker: docker run -i -t -rm -e a=”hello world” b=world ubuntu /bin/bash What it does is passes env var a with value “hello world” and env var b with value “world” into the docker container. Thing is, I need to generate that from script. It is super easy to get […]

How can I reproduce zombie process with bash as PID1 in docker?

I have a Docker container that runs bash at PID1 which in turn runs a long-running (complex) service that sometimes produces zombie processes parented to the bash at PID1. These zombies are seemingly never reaped. I’m trying to reproduce this issue in a minimal container so that I can test mitigations, such as using a […]

How can I keep a docker debian container open?

I want to use a debian Docker container to test something, and by this I mean execute some commands in the debian bash console. I tried downloading the image using docker pull debian and then running it using docker run debian, but I get no output. What am I doing wrong? Shouldn’t the docker container […]

What do the curly braces mean in docker inspect –format “{{.State.Pid}}”?

I’m looking through this shell script and I’m curious what the double curly braces are doing in this line: https://github.com/jpetazzo/nsenter/blob/master/docker-enter#L16 I know that curly braces in shell are used for grouping, but what does two sets of curly braces do? If someone could explain this: docker inspect –format “{{.State.Pid}}” I would really appreciate it.

Ctrl-p and Ctrl-n behaving unexpectedly under Docker

For the life of me I can’t seem to figure out why ctrl–p and ctrl–n don’t work like they’re supposed to under the Docker images I have been working with. ctrl–p should work just like the up arrow but I usually have to press it twice to get the last command I ran. And it […]

How to persist 'ln' in Docker with Ubuntu

I have a Docker machine that I’m installing OpenCV 2.4.11 However, there is an error happening that I indeed found a solution, but it’s temporary. When I run my Python script that uses cv2, throws this error message: Error: libdc1394 error: Failed to initialize libdc1394 I saw that this is the only thread that fixed […]

Using variable interpolation in string in Docker

I am having trouble creating and using variables in a Dockerfile – I build a Docker image via a Dockerfile with this command: $ docker build –build-arg s=scripts/a.sh -t a . (So because I use –build-arg, $s will be an available argument in the Dockerfile, and this part works) The Dockerfile is like so: ARG […]

Docker: bash terminal starts without prompt

I have a simple container that looks like this: FROM devbox/rails3.2.1 RUN apt-get install -y -q libmysql-ruby libmysqlclient-dev RUN apt-get install -y -q libqtwebkit-dev EXPOSE 3000 CMD /bin/bash where devbox/rails3.2.1 is a container I made that starts with ‘FROM ubuntu‘ and installs Ruby on Rails. This is a running in a Vagrant Virtual Box VM […]

Automatically configure Java to use the maximum RAM allocated to its Docker container

If I do docker run –memory=X to run a Java app through a Bash script, is there any way to get this Bash script to reliably infer how much memory has been allocated to the container? Basically, I want this Bash script to do something like: #!/bin/bash # (Do some other stuff…) MAX_RAM=”$(get-max-ram)” exec java […]

Running a longer command from docker

I am using Docker to write a file on the fly and run it. The command looks like this so far (just to test the idea first): docker run dockerfile/python cat <<EOF >hi.txt && tail hi.txt > hi there > EOF For some reason this does not echo anything. If I run this command without […]

Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.