Tag: bash

How can I set the current working directory for docker exec with an internal bash shell?

I have a developer docker image based on ubuntu:14.04 that I use to develop apps for Ubuntu 14.04. I start this image when the machine boots with docker start image-name My home directory was bind mounted with –volumes when initially created. To enter the image I have an alias defined in .bash_aliases alias d_enter=”docker exec […]

How to access the metadata of a docker container from a script running inside the container?

I am trying to understand whether it is possible to read the metadata (Labels, in particular) properties of a container using a bash script. For instance, if there is a Dockerfile like: FROM busybox LABEL abc = abc_value1 And, if I build and run an image based on the file above, like so: docker build […]

How to avoid undesired “animated” console output on Jenkins

Sometimes I find log-lines like these in my Jenkins Job Output: [|] [/] [-] [\] [|] [/] [-] [\] [|] [/] [-] I know these lines come from a “Progress Spinner” (https://askubuntu.com/questions/623933/how-to-create-a-rotation-animation-using-shell-script) but they look weird in a plain-text log. It gets worse, when a tool uses a “command line progress bar” which comes e.g. […]

Eval in docker-machine: terminal vs shell script

I’m trying to run a simple shell script to automate changing docker-machine environments. The problem is this, when I run the following command directly in the Mac terminal the following is outputted: eval $(docker-machine env default) docker-machine ls NAME ACTIVE DRIVER STATE URL SWARM DOCKER ERRORS default * digitalocean Running tcp://***.**.***.***:**** v1.12.0 So basically what […]

How to pass host ip address to docker in mac OS?

I am working on Linux machine and I wrote an script to pass local host IP address to docker container by passing an parameter It works fine for ubuntu. will the same script run on mac OS and work as expected (pass IP address of local host to docker container)? docker run -t -i -e […]

How to get local host IP address in docker container?

I am using docker and run using script. I want to change in one of configuration with host machine IP address in docker. #!/bin/bash IP=$(echo `ifconfig eth0 2>/dev/null|awk ‘/inet addr:/ {print $2}’|sed ‘s/addr://’`) echo Setting xwiki config IP CONFIG=/xwiki/webapps/xwiki/WEB-INF/xwiki.cfg sed -i -e “s/^xwiki.authentication.authhost=localhost*/xwiki.authentication.authhost= $IP/” $CONFIG /xwiki/start_xwiki.sh -f I run my docker with following command. docker […]

Docker disconnect all containers from docker network

I have docker network “my_network”. I want to remove this docker network with docker network rm my_network. Before it I should disconnect all my containers from this network. I can use docker network inspect and get output like [ { “Name”: “my_network”, “Id”: “aaaaaa”, “Scope”: “some_value”, “Driver”: “another_value”, “EnableIPv6”: bool_value, “IPAM”: { “Driver”: “default”, “Options”: […]

Make docker container run forever while being able to gracefully stop

I am trying to create a docker container. It is supposed to run forever in background. But whenever I press Ctrl+C or docker stop, it should close without wasting any further time. My current code #RUN trap ‘echo $excode’ EXIT HUP INT QUIT PIPE TERM ENTRYPOINT while :; do read; done #ENTRYPOINT trap “exit 1” […]

Docker run command error

I have just installed docker and pulled their official ubuntu image following their documentation installation tutorial. However, when I get to the point of executing a command in a specific container, I end up with the following error: Error: Cannot start container f6e1084236794548bbd5cd059f46f916367106bf38ec24ad30ceefb9fb015291: fork/exec /var/lib/docker/containers/f6e1084236794548bbd5cd059f46f916367106bf38ec24ad30ceefb9fb015291/root/.dockerinit: invalid argument it happens either I run: sudo docker run […]

Access mongo shell running in docker container in linux script

I want to create a bash script that removes a user from a mongodb database that is running inside a docker container. Normally through the terminal I would execute docker exec -it mycontainername bash and then once I’m in the container I execute mongo mydbname –eval “db.users.remove({“firstname”:”Bob”})” I just have no idea how to do […]

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