Tag: bash

Docker osx mounted folder is empty

I tried to mount folder of my project from /var/www to the same folder in container but folder in container is empty. Problem is maybe with host folder permissions because if i try that with some other folder it works. This works: docker run -it -v ~/Downloads:/var/www debian:jessie /bin/bash This doesn’t work: docker run -it […]

use docker exec in bash script

I have a bash script that is supposed to execute other bash scripts using “docker exec” which are installed in different docker containers. Although each command works correctly when started manually, the script stops after the execution of first docker exec command. Example: #!/bin/bash … docker exec -it mysql_container /scripts/import_database.sh ## Scripts stops here… docker […]

$(pwd) – one level up

I’m pretty new to the bash/shell script world, I’m trying to do the below and it could be pretty simple but I wasn’t able to figure out the command, would be great if someone could help me out here and also point me to some documentation wrt to shell script topics. Thank you in advance. […]

Echo printing variables in a completely wrong order

I am trying to create a string with a query that will be save / send to another location, this string contains different variables. The issue that I am having is that the echo of the variables are completely upside down and mix. See code below: tokenID=$(docker exec -ti $dockerContainerID /bin/sh -c “cat /tempdir/tokenfile.txt”) serverName=”asdasd” […]

Setting environment variables when running docker in detached mode

If I include the following line in /root/.bashrc: export $A = “AAA” then when I run the docker container in interactive mode (docker run -i), the $A variable keeps its value. However if I run the container in detached mode I cannot access the variable. Even if I run the container explicitly sourcing the .bashrc […]

How to close and reopen docker terminal

I am installing nvm inside docker. After I’ve finished installing it says to run echo “. ~/.nvm/nvm.sh” >> ~/.bash_profile and then close and reopen terminal. I think the above procedure updates bash profile and let me access nvm.sh from bash with nvm command. But, to do this, I have to close and reopen bash/terminal. Is […]

How to answer command line prompts in script in docker

I’m running a Dockerfile which looks like this: FROM alexhermstad/arch-pypi2pkgbuild-kolibri MAINTAINER Alex Hermstad USER kol WORKDIR /home/kol/pypi2pkgbuild CMD [“python”, “./pypi2pkgbuild.py”, “–pre”, “kolibri”] Within pypi2pkgbuild.py, there’s a prompt that comes up, which says: :: Proceed with installation? [Y/n] Is there anyway that I can use docker to automatically press ‘n’ to skip the installation? I searched […]

Cannot run script added to existing docker container

I have a container that is running with no issues. I added a bash script to compliment a couple other scripts already in the container. The docker image copy 2 scripts to /usr/local/bin and they can be accessed with docker exec -c container-name existingscript. I added my own script to the same directory and when […]

Can't attach to bash running the Docker container

Having troubles with attaching to the bash instance keeping the container running. To be more detailed. I am running container as here: $ docker run -dt –name test ubuntu bash Now it should be actually running, not finished. $ docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES f3596c613cfe ubuntu “bash” 4 seconds ago […]

`docker run` output to bash variable – strange behaviour

I’m seeing some strange behaviour getting the output from docker run into a bash variable. Simple example: #!/bin/bash PWD=$(docker run –rm -ti ubuntu pwd 2>&1) # also tried with PWD=`docker run …` with same behaviour echo $PWD echo abc $PWD echo abc $PWD xyz output / abc / xyz/ The problem is on the last […]

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