Tag: bash

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 […]

stop and delete docker container if its running

I am looking to pragmatically stop and delete a docker container if it is running. This is for a build script. Take the following example. How would I stop and delete the docker container “rabbitmq” as seen under the NAMES column in a bash script. docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES […]

trapping signal from “docker stop” in bash

i have an entry point script in a docker container that looks something like the following: #!/bin/bash echo starting up function shut_down() { echo shutting down pid=$(ps -e | grep myapp | awk ‘{print $1}’) kill -SIGTERM $pid exit } trap “shut_down” SIGKILL SIGTERM SIGHUP SIGINT EXIT /opt/myapp I can’t figure out how to trap […]

Docker bash prompt not display color

I use command: docker run –rm -it govim bash -l to run docker images but it cannot display bash prompt color. If I source ~/.bash_profile or run bash -l again, bash prompt display color like normal. Bash Prompt Image My bash_profile and bash_prompt

Redirecting command output in docker

I want to do some simple logging for my server which is a small Flask app running in a Docker container. Here is the Dockerfile # Dockerfile FROM dreen/flask MAINTAINER dreen WORKDIR /srv # Get source RUN mkdir -p /srv COPY perfektimprezy.tar.gz /srv/perfektimprezy.tar.gz RUN tar x -f perfektimprezy.tar.gz RUN rm perfektimprezy.tar.gz # Run server EXPOSE […]

Check if image:tag combination already exists on docker hub

As part of a bash script, I want to check if a particularly docker image:tag combination exists on docker hub. Also, it will be a private repository. i.e. the pseudocode would be like: tag = something if image:tag already exists on docker hub: Do nothing else Build and push docker image with that tag

docker-compose yml running a script after up

I want to run a script, right after running `docker-compose up -d` Here is my snippet of docker-compose.yml . The other settings are mysql server, redis…etc….but they are not causing any problems web: image: nginx container_name: web-project volumes: – ./code:/srv working_dir: /srv/myweb extra_hosts: – “myweb.local:127.0.0.1” ports: – 8081:80 # tty: true command: sh /srv/scripts/post-run-web.sh So […]

How do I check if my local docker image is outdated, without pushing from somewhere else?

I’m running a react app in a docker container, on a Coreos server. Let’s say it’s been pulled from dockerhub from https://hub.docker.com/r/myimages/myapp. Now I want to check periodically if the dockerhub image for the app container has been updated, to see if the image I’m running locally is behind. What would be the most efficient […]

How to detect if docker run succeeded programmatically?

I’m writing a very simple bash script to quickly check that my container still builds and starts correctly and that the app inside responds to requests. Sometimes docker run fails, e.g. because the port I’m trying to bind the container to is already allocated. But when this happens docker run‘s exit code is still 0 […]

Determining if a process runs inside lxc/Docker

Is there any way to determine if a process (script) runs inside an lxc container (~ Docker runtime)? I know that some programs are able to detect whether they run inside a virtual machine, is something similar available for lxc/docker?

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