Tag: bash

Dockerfile: How to replace a placeholder in environment variable with build-arg's?

I have a web application which I want to run on Docker for testing purposes. The application uses a database as storage and the configuration for the database is maintained in an environment variable (JSON). Below you can see the env variable definition in my Dockerfile (see also my approaches below) ENV CONFIG ‘{ \ […]

How can I force cancel dockerbuild using bash a command?

The reason why I’m asking is because we’re using AWS codebuild & I need to do DB migrations. If a DB migration breaks, I want to cancel the codebuild & rollback the migration which was just made. I’ve got this part working, all I need to do now is cancel the dockerbuild mid way. How […]

Docker 1.9: Adding –link target to a running nginx container

Question: I’m deploying on docker 1.9 I run an nginx container first: docker run \ –name=nginx \ –link=php1:php1 \ –link=php2:php2 \ –restart=always \ -p 80:80 -p 443:443 \ -v /var/docker/nginx/conf.d:/etc/nginx/conf.d \ -d nginx:latest Note that I linked two exist php containers: php1 and php2. Now I started a new container php3. Can I add a […]

How to run linux command before starting up git bash terminal

I am working with Docker on my windows machine via git bash. Since git bash does not record the current status on closing, I need to set some environment variables related to Docker every time when I start a new terminal. The command I would like to run before start-up is: eval $(docker-machine env) Or […]

How to substitute a command output into a string and append that to a file (in Alpine Linux running in Docker)

I’m trying to build the following Dockerfile: FROM alpine:latest EXPOSE 9050 9051 RUN apk –update add tor RUN echo “ControlPort 9051” >> /etc/tor/torrc RUN password_hash=$(tor –hash-password “foo”) RUN echo “HashedControlPassword $password_hash” >> /etc/tor/torrc CMD [“tor”] I’m trying to add the line HashedControllPassword [pw] to /etc/tor/torrc, where [pw] is generated by the command tor –hash-password “foo”. […]

start multiple docker containers with a single command line shell script (without docker-compose)

I’ve got 3 containers that will run on a single server, which we’ll call: A,B,C Each server has a script on the host that has the commands to start docker: A_start.sh B_start.sh C_start.sh I’m trying to create a swarm script to start them all, but not sure how. ABC_start.sh UPDATE: this seems to work, with […]

Docker $(pwd) and bash aliases

I’m running Docker CE in Ubuntu 16.04. I’ve created a Docker image for the polymer-cli. The idea is to be able to run polymer commands from inside disposable docker containers using bash aliases that mount the current directory, run the command and then destroy the container, like this: docker run –rm -it -v $(pwd):/home/node/app -u […]

How to check ruby version inside docker container

I have build the docker container by creating below docker file # Select ubuntu as the base image FROM ubuntu # Install nginx, nodejs and curl RUN apt-get update -q RUN apt-get install -qy nginx RUN apt-get install -qy curl RUN apt-get install -qy nodejs RUN echo “daemon off;” >> /etc/nginx/nginx.conf # Install rvm, ruby, […]

Docker: RUN touch doesn't create file

While trying to debug a RUN statements in my Dockerfile, I attempted to redirect output to a file in a bound volume (./mongo/log). To my surprise I was unable to create files via the RUN command, or to pipe the output of another command to a file using the redirection/appending (>,>>) operators. I was however […]

Run Boot2Docker from bash

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 run some docker’s commands. Something […]

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