Tag: bash

How to check if docker machine exists programmatically?

I’m using docker-machine to manage my cloud servers. I’m writing some bash scripts to automate some tasks. The question is: “How to check in bash script if docker machine with the specific name already exists?”. I need some expression to return true if it exists and false if it doesn’t. Thanks

What purpose does using exec in docker entrypoint scripts serve?

For example in the redis official image: https://github.com/docker-library/redis/blob/master/2.8/docker-entrypoint.sh #!/bin/bash set -e if [ “$1” = ‘redis-server’ ]; then chown -R redis . exec gosu redis “$@” fi exec “$@” Why not just run the commands as usual without exec preceding them?

Docker and .bash_history

Is there any way to share a .bash_history volume with a docker container so that everytime I go into a shell I have my bash history available for scrolling through? Would be awesome to be able to do the same thing with IPython too.

How do I know when my docker mysql container is up and mysql is ready for taking queries?

I am deploying a few different docker containers, mysql being the first one. I want to run scripts as soon as database is up and proceed to building other containers. The script has been failing because it was trying to run when the entrypoint script, which sets up mysql (from this official mysql container), was […]

How to edit files in stopped/not starting docker container

Trying to fix errors and debug problems with my application that is split over several containers, I frequently edit files in containers: either I am totally lazy and install nano and edit directly in container or I docker cp the file out of the container, edit it, copy it back and restart the container Those […]

Bash / Docker exec: file redirection from inside a container

I can’t figure out how to read content of a file from a Docker container. I want to execute content of a SQL file into my PGSQL container. I tried: docker exec -it app_pgsql psql –host= –username=foo foo < /usr/src/app/migrations/*.sql My application is mounted in /usr/src/app. But I got an error: bash: /usr/src/app/migrations/*.sql: No such […]

How to set bash aliases for docker containers in Dockerfile?

I am new to docker. I found that we can set environment variables using ENV instruction in the Dockerfile. But how does one set bash aliases for long commands in Dockerfile?

how to set supervisor to run a shell script

Setting up a Dockerfile to install node prereqs and then set up supervisor in order to run the final npm install command. Running Docker in CoreOS under VirtualBox. I have a Dockerfile that sets everything up correctly: FROM ubuntu MAINTAINER <<Me>> # Install docker basics RUN echo “deb http://archive.ubuntu.com/ubuntu precise main universe” > /etc/apt/sources.list RUN […]

Commands to execute background process in Docker CMD

I am creating a docker image using a Dockerfile. I would like to execute some scripts while starting the docker container. Currently I have a shell script to execute all the necessary processes CMD [“sh”,”start.sh”] I would like to execute a shell command with a process running in background example CMD [“sh”, “-c”, “mongod –dbpath […]

Why do I have to use bash -l -c inside my container?

I’ve created a docker container using the following Dockerfile (truncated): FROM ubuntu:12.04 # curl enables downloading of other things RUN apt-get install curl -y # download and install rvm… RUN \curl -L https://get.rvm.io | bash -s stable # … so that we can install ruby RUN /bin/bash -l -c “rvm requirements” And so on. This […]

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