Tag: bash

Docker unable to start an interactive shell if the image has an entry script

My custom-made image ends with ENTRYPOINT [ “/bin/bash”, “-c”, “/home/tool/entry_script.sh” ] This is absolutely needed because at runtime, the first thing the user must do is to update an already cloned github project, and users will often forget to do it. But then, when i try to launch using docker run -it –rm my_image /bin/bash […]

Cannot exec into docker container due to application

Yesterday I restarted my docker container for my database. My applications can still connect as normal however: The following line no-longer works docker exec -i -t database_1 bash Instead it gives me this error: unable to find user postgres: no matching entries in passwd file I don’t know why it’s not just giving me bash

Properly automate a docker script in Python

Based on this tutorial to build a TF image classifier, I have a bash shell in which I run a Docker image with the following command: docker run –name fooldocker -it -v $HOME/tf_files:/tf_files/ gcr.io/tensorflow/tensorflow:latest-devel And then in this docker image I run my Python script: python /tf_files/label_image.py /tf_files/myimages exit It works. But now, I need […]

Docker Entrypoint Why I get the wrong parameter

I am making a custom docker image having this Dockerfile # Dockerfile for moodle instance. # Forked from Jonathan Hardison’s <jmh@jonathanhardison.com> docker version. https://github.com/jmhardison/docker-moodle FROM php:7.0-apache MAINTAINER Dimitrios Desyllas <ddesyllas@freemail.gr> #Original Maintainer Jon Auer <jda@coldshore.com> VOLUME [“/var/moodledata”] EXPOSE 80 # Let the container know that there is no tty ENV DEBIAN_FRONTEND noninteractive # Moodle Info […]

Running docker commands in bash script leads to segmentation fault

The commands are like: docker run / stop / rm … which works in terminal while causes segmentation fault in bash script. I compared the environments between bash script and terminal, as shown below. 2c2 < BASHOPTS=cmdhist:complete_fullquote:extquote:force_fignore:hostcomplete:interactive_comments:progcomp:promptvars:sourcepath — > BASHOPTS=cmdhist:complete_fullquote:expand_aliases:extquote:force_fignore:hostcomplete:interactive_comments:login_shell:progcomp:promptvars:sourcepath 7,8c7,8 < BASH_LINENO=([0]=”0″) < BASH_SOURCE=([0]=”./devRun.sh”) — > BASH_LINENO=() > BASH_SOURCE=() 10a11 > COLUMNS=180 14a16,18 > […]

How to execute a command from the host when it's on the $PATH?

I am installing the Laravel Installer as part of a Docker container using Composer. Laravel is installed globally meaning it goes to ~/.composer/vendor and then add an executable under ~/.composer/vendor/bin. I am adding the directory ~/.composer/vendor/bin to the $PATH in a Dockerfile as follow: ENV PATH=”~/.composer/vendor/bin:${PATH}” If I run the command docker exec -it php-fpm […]

prepend command with env variable – including sub command

I need to add an environment variable to the php artisan migrate commands of Laravel for use with docker, like: env DB_HOST= php artisan migrate I created a function in my .zshrc file like this: function migrate() { (env DB_HOST= php artisan migrate $*) } however the way Laravel’s command structure works is like this: […]

Bad substitution [duplicate]

This question already has an answer here: “bash: Bad substitution” when using code in .sh file 2 answers

Jenkins shell script add Unix user to group

I am running two consecutive shell scripts in a Jenkinsfile: stage(‘running scripts’) { sh “sudo script1.sh” sh “groups && whoami” } script1.sh: groupadd docker usermod -aG docker ubuntu groups ubuntu Console output is: ubuntu : ubuntu adm dialout cdrom floppy sudo audio dip video plugdev netdev lxd docker But second shell script (i.e: sh “groups […]

Executing bash then running commands in docker

You can execute a bash shell in a docker container by using sudo docker exec -it container bash But I want a command that executes a bash shell in the container and then executes more commands in the bash prompt. A command like this currently works: sudo docker exec -it container touch test.txt | bash […]

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