Tag: bash

Bash restore database to a docker container for a WordPress + Piwik Solution

For the https://github.com/ellakcy/piwik-with-wordpress I am making a restore bash script in order to restore the backup generated from the https://github.com/ellakcy/piwik-with-wordpress/blob/master/scripts/pre-backup script The main idea is to set a path with a tarball containing the backup and recreating the folders that volumes are mounted. The script is the following: #!/bin/bash # Printing functions black=’\E[30;40m’ red=’\E[31;40m’ green=’\E[32;40m’ […]

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=127.0.0.1 php artisan migrate I created a function in my .zshrc file like this: function migrate() { (env DB_HOST=127.0.0.1 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 […]

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