Skip to content
New issue

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

can't use docker from bash script on OSX #20063

Closed
ebuchman opened this issue Feb 6, 2016 · 3 comments
Closed

can't use docker from bash script on OSX #20063

ebuchman opened this issue Feb 6, 2016 · 3 comments

Comments

@ebuchman
Copy link

ebuchman commented Feb 6, 2016

BUG REPORT INFORMATION

docker version:

Client:
 Version:      1.10.0
 API version:  1.22
 Go version:   go1.5.3
 Git commit:   590d510
 Built:        Fri Feb  5 08:21:41 UTC 2016
 OS/Arch:      darwin/amd64

Server:
 Version:      1.10.0
 API version:  1.22
 Go version:   go1.5.3
 Git commit:   590d5108
 Built:        Thu Feb  4 18:41:30 2016
 OS/Arch:      linux/amd64
captaincandy:functional-tester$ docker-machine version
docker-machine version 0.6.0, build e27fb87

docker info:

captaincandy:functional-tester$ docker info
Containers: 0
 Running: 0
 Paused: 0
 Stopped: 0
Images: 24
Server Version: 1.10.0
Storage Driver: aufs
 Root Dir: /var/lib/docker/aufs
 Backing Filesystem: extfs
 Dirs: 32
 Dirperm1 Supported: true
Execution Driver: native-0.2
Logging Driver: json-file
Plugins: 
 Volume: local
 Network: null host bridge
Kernel Version: 4.2.0-27-generic
Operating System: Ubuntu 15.10
OSType: linux
Architecture: x86_64
CPUs: 1
Total Memory: 488.9 MiB
Name: test1
ID: CSKG:63K5:CXTZ:4GBU:JVEM:XF7D:7WMU:TKGH:UGAO:VV4U:5JU5:QEYT
Username: tendermint
Registry: https://index.docker.io/v1/
WARNING: No swap limit support
Labels:
 provider=digitalocean
captaincandy:functional-tester$ uname -v
Darwin Kernel Version 15.3.0: Thu Dec 10 18:40:58 PST 2015; root:xnu-3248.30.4~1/RELEASE_X86_64
captaincandy:functional-tester$ sw_vers
ProductName:    Mac OS X
ProductVersion: 10.11.3
BuildVersion:   15D21

Both docker and docker-machine were installed via brew.

I launched a machine on digital ocean:

captaincandy:functional-tester$ docker-machine config test1
--tlsverify
--tlscacert="/Users/captaincandy/.docker/machine/certs/ca.pem"
--tlscert="/Users/captaincandy/.docker/machine/certs/cert.pem"
--tlskey="/Users/captaincandy/.docker/machine/certs/key.pem"
-H=tcp://104.236.36.179:2376
captaincandy:functional-tester$ env | grep DOCKER
DOCKER_HOST=tcp://104.236.36.179:2376
DOCKER_OPTS=-H tcp://104.236.36.179:2376 --tls --tlskey /Users/captaincandy/.docker/machine/machines/test1/server-key.pem    --tlscert /Users/captaincandy/.docker/machine/machines/test1/server.pem --tlsverify --tlscacert /Users/captaincandy/.docker/machine/machines/test1/ca.pem
DOCKER_MACHINE_NAME=test1
DOCKER_TLS_VERIFY=1
DOCKER_CERT_PATH=/Users/captaincandy/.docker/machine/machines/test1

I can see my (lack of) containers on the machine just fine:

captaincandy:functional-tester$ docker ps -a
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES

If I try to run the same command from a bash script, it fails:

captaincandy:functional-tester$ cat docker.sh 
docker ps -a
captaincandy:functional-tester$ bash docker.sh 
The server probably has client authentication (--tlsverify) enabled. Please check your TLS client certification settings: Get https://104.236.36.179:2376/v1.22/containers/json?all=1: remote error: bad certificate

but if I run it with source, it works:

captaincandy:functional-tester$ source docker.sh 
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES
captaincandy:functional-tester$ 

even though the environment variables are the same!

captaincandy:functional-tester$ env | grep DOCKER
DOCKER_HOST=tcp://104.236.36.179:2376
DOCKER_OPTS=-H tcp://104.236.36.179:2376 --tls --tlskey /Users/captaincandy/.docker/machine/machines/test1/server-key.pem    --tlscert /Users/captaincandy/.docker/machine/machines/test1/server.pem --tlsverify --tlscacert /Users/captaincandy/.docker/machine/machines/test1/ca.pem 
DOCKER_MACHINE_NAME=test1
DOCKER_TLS_VERIFY=1
DOCKER_CERT_PATH=/Users/captaincandy/.docker/machine/machines/test1
captaincandy:functional-tester$ cat docker.sh 
env | grep DOCKER
docker ps -a
captaincandy:functional-tester$ bash docker.sh 
DOCKER_HOST=tcp://104.236.36.179:2376
DOCKER_OPTS=-H tcp://104.236.36.179:2376 --tls --tlskey /Users/captaincandy/.docker/machine/machines/test1/server-key.pem    --tlscert /Users/captaincandy/.docker/machine/machines/test1/server.pem --tlsverify --tlscacert /Users/captaincandy/.docker/machine/machines/test1/ca.pem 
DOCKER_MACHINE_NAME=test1
DOCKER_TLS_VERIFY=1
DOCKER_CERT_PATH=/Users/captaincandy/.docker/machine/machines/test1
The server probably has client authentication (--tlsverify) enabled. Please check your TLS client certification settings: Get https://104.236.36.179:2376/v1.22/containers/json?all=1: remote error: bad certificate
captaincandy:functional-tester$ 

What's going on here?

Furthermore, you may have noticed I'm using DOCKER_OPTS. Why must I use DOCKER_OPTS if the relevant env variables (DOCKER_HOST, etc.) are already set? Could this be relevant?

----------END REPORT ---------

@GordonTheTurtle
Copy link

If you are reporting a new issue, make sure that we do not have any duplicates already open. You can ensure this by searching the issue list for this repository. If there is a duplicate, please close your issue and add a comment to the existing issue instead.

If you suspect your issue is a bug, please edit your issue description to include the BUG REPORT INFORMATION shown below. If you fail to provide this information within 7 days, we cannot debug your issue and will close it. We will, however, reopen it if you later provide the information.

For more information about reporting issues, see CONTRIBUTING.md.

You don't have to include this information if this is a feature request

(This is an automated, informational response)


BUG REPORT INFORMATION

Use the commands below to provide key information from your environment:

docker version:
docker info:

Provide additional environment details (AWS, VirtualBox, physical, etc.):

List the steps to reproduce the issue:
1.
2.
3.

Describe the results you received:

Describe the results you expected:

Provide additional info you think is important:

----------END REPORT ---------

#ENEEDMOREINFO

@ebuchman ebuchman changed the title can't use docker from bash script can't use docker from bash script on OSX Feb 6, 2016
@albers
Copy link
Member

albers commented Feb 8, 2016

Maybe you did not export the DOCKER_ variables?

@thaJeztah
Copy link
Member

closing because this went stale

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants