We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dockerfile:
FROM ubuntu RUN echo 'export GOROOT=/root/go' >> /root/.bashrc && \ /bin/bash -c 'source /root/.bashrc && echo $GOROOT'
When i build images, echo $GOROOT will Printout empty, but if i change the dockerfile like this:
echo $GOROOT
FROM ubuntu RUN echo 'export GOROOT=/root/go' >> /root/bashrc && \ /bin/bash -c 'source /root/bashrc && echo $GOROOT'
echo $GOROOT will Printout /root/go
/root/go
# docker build --no-cache -t test . Sending build context to Docker daemon 2.048kB Step 1/2 : FROM ubuntu ---> 735f80812f90 Step 2/2 : RUN echo 'export GOROOT=/root/go' >> /root/bashrc && /bin/bash -c 'source /root/bashrc && echo $GOROOT' ---> Running in de6fef00ad5e /root/go Removing intermediate container de6fef00ad5e ---> 4c43192410df Successfully built 4c43192410df Successfully tagged test:latest
# docker build --no-cache -t test . Sending build context to Docker daemon 2.048kB Step 1/2 : FROM ubuntu ---> 735f80812f90 Step 2/2 : RUN echo 'export GOROOT=/root/go' >> /root/.bashrc && /bin/bash -c 'source /root/.bashrc && echo $GOROOT' ---> Running in 5a4e9c4fb915 Removing intermediate container 5a4e9c4fb915 ---> 3e9d88bcc1b1 Successfully built 3e9d88bcc1b1 Successfully tagged test:latest
Output of docker version:
docker version
# docker version Client: Version: 18.06.0-ce API version: 1.38 Go version: go1.10.3 Git commit: 0ffa825 Built: Wed Jul 18 19:11:02 2018 OS/Arch: linux/amd64 Experimental: false Server: Engine: Version: 18.06.0-ce API version: 1.38 (minimum version 1.12) Go version: go1.10.3 Git commit: 0ffa825 Built: Wed Jul 18 19:09:05 2018 OS/Arch: linux/amd64 Experimental: false
Output of docker info:
docker info
# docker version Client: Version: 18.06.0-ce API version: 1.38 Go version: go1.10.3 Git commit: 0ffa825 Built: Wed Jul 18 19:11:02 2018 OS/Arch: linux/amd64 Experimental: false Server: Engine: Version: 18.06.0-ce API version: 1.38 (minimum version 1.12) Go version: go1.10.3 Git commit: 0ffa825 Built: Wed Jul 18 19:09:05 2018 OS/Arch: linux/amd64 Experimental: false root@iZj6ccusv1f4owdo0s9szyZ:~/nes/3# docker info Containers: 39 Running: 2 Paused: 0 Stopped: 37 Images: 89 Server Version: 18.06.0-ce Storage Driver: overlay2 Backing Filesystem: extfs Supports d_type: true Native Overlay Diff: true Logging Driver: json-file Cgroup Driver: cgroupfs Plugins: Volume: local Network: bridge host macvlan null overlay Log: awslogs fluentd gcplogs gelf journald json-file logentries splunk syslog Swarm: inactive Runtimes: runc Default Runtime: runc Init Binary: docker-init containerd version: d64c661f1d51c48782c9cec8fda7604785f93587 runc version: 69663f0bd4b60df09991c08812a60108003fa340 init version: fec3683 Security Options: apparmor seccomp Profile: default Kernel Version: 4.15.0-24-lowlatency Operating System: Ubuntu 16.04.5 LTS OSType: linux Architecture: x86_64 CPUs: 4 Total Memory: 7.789GiB Name: iZj6ccusv1f4owdo0s9szyZ ID: 4N46:JD4L:GRWZ:SFHH:3JJS:AJ4G:SX3D:E7QE:QVWF:5P7L:JFOC:RJFL Docker Root Dir: /var/lib/docker Debug Mode (client): false Debug Mode (server): false Username: zjb0807 Registry: https://index.docker.io/v1/ Labels: Experimental: false Insecure Registries: 127.0.0.0/8 Live Restore Enabled: false WARNING: No swap limit support
Additional environment details (AWS, VirtualBox, physical, etc.) Aliyun ECS(Elastic Compute Service) , just like AWS
The text was updated successfully, but these errors were encountered:
Do you need to define GOROOT through your .bashrc?
GOROOT
.bashrc
Wouldn't it be better to define it as an ENV directive?
ENV
FROM ubuntu ENV GOROOT /root/go RUN echo ${GOROOT}
Sorry, something went wrong.
I know this,I just want to know why the /root/.bashrc file doesn't work, but the /root/bashrc file does
The problem still exists even in a basic VM:
vagrant@ubuntu-bionic:~$ echo 'export GOROOT=$HOME/go' >> $HOME/.bashrc && /bin/bash -c 'source $HOME/.bashrc && echo $GOROOT'
This doesn't appear to be an issue with docker so I'm going to close this but I am curious as to why it doesn't work.
Maybe It's because you are not running interactively when use /bin/bash -c 'source xxx'. In the first few line of .bashrc, it writes
# If not running interactively, don't do anything [ -z "$PS1" ] && return
So, when use /bin/bash -c 'source xxx', it return immediately.
No branches or pull requests
Dockerfile:
When i build images,
echo $GOROOT
will Printout empty, but if i change the dockerfile like this:echo $GOROOT
will Printout/root/go
Expected behavior
Actual behavior
Steps to reproduce the behavior
Output of
docker version
:Output of
docker info
:Additional environment details (AWS, VirtualBox, physical, etc.)
Aliyun ECS(Elastic Compute Service) , just like AWS
The text was updated successfully, but these errors were encountered: