Tag: bash

docker run -i -t image /bin/bash – source files first

This works: # echo 1 and exit: $ docker run -i -t image /bin/bash -c “echo 1” 1 # exit # echo 1 and return shell in docker container: $ docker run -i -t image /bin/bash -c “echo 1; /bin/bash” 1 root@4c064f2554de:/# Question: How could I source a file into the shell? (this does not […]

anyway to setup npm credentials over `npm login` without reading input from STDIN?

I’m trying to automate npm publish inside a docker container but I got trouble when $npm login command tries to read username and email from prompts: npm login << EOF username password email EOF it works in terminal bash but not in container without STDIN open and show the following error message: Username: Password: npm […]

Error: Postgres database import in docker container

I’m running a ruby on rails application in docker container. I want to create and then restore the database dump in postgres container. But I’m Below is what I’ve done so far: 1) Added bash script in /docker-entrypoint-initdb.d folder. Script is just to create database: psql -U docker -d postgres -c ‘create database dbname;’ RESULT: […]

docker entrypoint running bash script gets “permission denied”

I’m trying to dockerize my node.js app. When the container is built I want it to run a git clone and then start the node server. Therefore I put these operations in a .sh script. And run the script as a single command in the ENTRYPOINT: FROM ubuntu:14.04 RUN apt-get update && apt-get install -y […]

Execute bash command if docker container does not exist

On a Jenkins machine I would like to create a docker container with a specified name only if it does not already exist (in a shell script). I thought I might run the command to create the container regardless and ignore the failure if there was one, but this causes my jenkins job to fail. […]

standard_init_linux.go:178: exec user process caused “exec format error”

docker started throwing this error: standard_init_linux.go:178: exec user process caused “exec format error” whenever I run a specific docker container with CMD or ENTRYPOINT, with no regard to any changes to the file other then removing CMD or ENTRYPOINT. here is the docker file I have been working with which worked perfectly until about an […]

How to run bash function in Dockerfile

I have a bash function nvm defined in /root/.profile. docker build failed to find that function when I call it in RUN step. RUN apt-get install -y curl build-essential libssl-dev && \ curl https://raw.githubusercontent.com/creationix/nvm/v0.16.1/install.sh | sh RUN nvm install 0.12 && \ nvm alias default 0.12 && \ nvm use 0.12 The error is Step […]

automatic docker login within a bash script

How can I preseed my credentials to docker login command within a script ? I’m using a bash script that basically automates the whole process of setting up my custom VMs etc, but when I need to login to docker within the script to pull the images, I get the following error: Username: FATA[0000] inappropriate […]

Docker exec – Write text to file in container

I want to write a line of text to a textfile INSIDE a running docker container. Here’s what I’ve tried so far: docker exec -d app_$i eval echo “server.url=$server_url” >> /home/app/.app/app.config Response: /home/user/.app/app.config: No such file or directory Second try: cfg_add=”echo ‘server.url=$server_url’ >> /home/user/.app/app.config” docker exec -i app_$i eval $cfg_add Response: exec: “eval”: executable file […]

How to know if a docker container is running in privileged mode

Would like to know via bash script, if current running container was started in –privileged mode from inside the container (not from the host machine). For now I’m stuck with passing an env var with the flag but is not an ideal solution.

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