HOME environment var ignore on version 0.9.11 and 0.9.12
bySabi opened this issue · comments
Using a minimal Docker file:
# mosquitto
# VERSION 0.0.2
FROM phusion/baseimage:0.9.12
MAINTAINER bySabi <flxinformatico@gmail.com>
# Set correct environment variables.
ENV DEBIAN_FRONTEND noninteractive
ENV HOME /root
ENV LANG en_US.UTF-8
ENV LC_ALL en_US.UTF-8
RUN \
echo "Europe/Madrid" > /etc/timezone && \
dpkg-reconfigure -f noninteractive tzdata
# Use baseimage-docker's init system.
CMD ["/sbin/my_init"]
and then connect docker image via ssh. I got this result changing phusion/baseimage
VERSION:
OK
Version: 0.9.10
root@d0891ea1ac6f:~# cat /etc/container_environment.json; echo
{"HOME": "/root", "HOSTNAME": "d0891ea1ac6f", "LANG": "en_US.UTF-8", "INITRD": "no", "TERM": "xterm", "PATH": "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin
WRONG ( HOME var ignored)
Version: 0.9.11
root@fab14d95caca:~# cat /etc/container_environment.json; echo
{"INITRD": "no", "PATH": "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin", "LANG": "en_US.UTF-8", "LC_ALL": "en_US.UTF-8", "TERM": "xterm", "DEBIAN_FRONTEND": "noninteractive", "HOSTNAME": "fab14d95caca"}
root@fab14d95caca:~#
Version: 0.9.12
root@96b682aed472:~# cat /etc/container_environment.json; echo
{"LANG": "en_US.UTF-8", "HOSTNAME": "96b682aed472", "DEBIAN_FRONTEND": "noninteractive", "LC_ALL": "en_US.UTF-8", "INITRD": "no", "TERM": "xterm", "PATH": "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"}
root@96b682aed472:~#
I have three HOME vars:
1- HOME is "" expanding from Ex: rc.local
2- HOME is "/root" from ssh
3- HOME is "/home/felix" using sudo docker-bash contID
Then my automated script running without shell fail with: not HOME defined.
The same applies to SHELL.
I also experienced this issue. This workaround seems to work for me so far in my Dockerfile to set HOME=/root
# Set correct environment variables.
#ENV HOME /root # FAILS TO WORK in 0.9.13
RUN echo /root > /etc/container_environment/HOME
Faced the same today in Docker 1.5.0 with baseimage 0.9.16
Proposed workaround helps, thanks to @grempe
We ignore HOME, SHELL, USER and a bunch of other environment variables on purpose, because not ignoring them will break multi-user containers. See #86
But I recognize that this causes confusion, so we should update the documentation accordingly.
Also faced the same today in Docker 1.11.2 with baseimage 0.9.18
Proposed workaround fixes, thanks to @grempe
I added this to the README.md: