Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

.bash_profile does not work with docker php image

There is my Dockerfile:

# https://hub.docker.com/_/php/
FROM php:5.5.23-fpm

USER www-data

ADD .bash_profile /var/www/.bash_profile

SHELL ["/bin/bash", "-c"]

RUN source /var/www/.bash_profile

Then after container built I run docker exec -it CONTAINER_NAME bash I did not see my aliases defined into /var/www/.bash_profile. But if I execute source /var/www/.bash_profile manually – everything is ok.

The same problem described here: https://github.com/docker/kitematic/issues/896 but no answer.

like image 583
Aliance Avatar asked Dec 06 '22 14:12

Aliance


1 Answers

Had a similar issue and the easiest solution was to use the -l option to bash to make bash act as if it had been invoked as a login shell.

docker run --rm -it $IMAGE /bin/bash -l

bash will then read in ~/.bash_profile

like image 154
docdocker Avatar answered Jan 07 '23 14:01

docdocker