Tag: bash

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:” 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?

Get Environment Variable from Docker Container

What’s the simplest way to get an environment variable from a docker container that has not been declared in the Dockerfile? For instance, an environment variable that has been set through some docker exec container /bin/bash session? I can do docker exec container env | grep ENV_VAR, but I would prefer something that just returns […]

How to create User/Database in script for Docker Postgres

I have been trying to set up a container for a development postgres instance by creating a custom user & database. I am using the official postgres docker image. In the documentation it instructs you to insert a bash script inside of the /docker-entrypoint-initdb.d/ folder to set up the database with any custom parameters. My […]

Docker timeout for container?

For my dissertation at University, I’m working on a coding leaderboard system where users can compile / run untrusted code through temporary docker containers. The system seems to be working well so far, but one problem I’m facing is that when code for an infinite loop is submitted, E.g: while True: print “infinite loop” the […]

Using the RUN instruction in a Dockerfile with 'source' does not work

I have a Dockerfile that I am putting together to install a vanilla python environment (into which I will be installing an app, but at a later date). FROM ubuntu:12.04 # required to build certain python libraries RUN apt-get install python-dev -y # install pip – canonical installation instructions from pip-installer.org # http://www.pip-installer.org/en/latest/installing.html ADD https://bitbucket.org/pypa/setuptools/raw/bootstrap/ez_setup.py […]

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