Can't build dockerfile in bamboo build

Wellington Silva February 9, 2015

I have made a script task to run during a build and it should build and start some docker containers based on dockerfiles but it gives me the following error:

Building proxy...
Couldn't connect to Docker daemon at http+unix://var/run/docker.sock - is it running?
If it's at a non-standard location, specify the URL with the DOCKER_HOST environment variable.

I have made some tests accessing ec2 instance and trying to run simple docker commands like

docker ps

When I run as bamboo or ec2-user user

su - bamboo -c "docker ps"
# or
su - ec2-user -c "docker ps"

it shows me the error:

su - bamboo -c "docker ps"
2015/02/09 12:34:05 Get http:///var/run/docker.sock/v1.14/containers/json: dial unix /var/run/docker.sock: permission denied
su - ec2-user -c "docker ps"
2015/02/09 12:34:05 Get http:///var/run/docker.sock/v1.14/containers/json: dial unix /var/run/docker.sock: permission denied

When I run as root it runs normally:

sudo docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES

 

What should I do to run this script?

 

1 answer

1 accepted

1 vote
Answer accepted
Pawel Skierczynski
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
February 9, 2015

There are two parts of it.

Docker service must be started as a root, so it's best done during system startup etc.

Docker client can be accessed with user that is not root but is in docker group. It depends on docker version as it was changing.

Look here: http://askubuntu.com/questions/477551/how-can-i-use-docker-without-sudo

Or here: https://docs.docker.com/installation/ubuntulinux/#giving-non-root-access

 

Wellington Silva February 9, 2015

Hello Pawel.

First of all I would like to thank you.
I made a change in the script task to run with "sudo".  It worked fine. I am facing another issue now: 

"...Service 'redis' failed to build: Error pulling image (unstable) from debian, Driver devicemapper failed to create image rootfs..."

Seems to be Device Mapper vs AUFS stuff. Anyway I am still searching. 

Thanks again.

Pawel Skierczynski
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
February 9, 2015

sudo is usually not the best option but it's simple so if it's enough for you that's ok too it seems race condition on device mapper is neverending story. Especially when building new image. Maybe as you suggest you can try switching to different storage. If docker and kernel is kind of new you could try "-s overlay" when starting docker service. You've probably seen this already: https://docs.docker.com/reference/commandline/cli/ (section "Daemon storage-driver option")

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events