Can't build dockerfile in bamboo build

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 votes

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

 

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.

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 Join to answer
Community showcase
Renan Battaglin
Published May 18, 2017 in Bamboo

FAQ: How to Upgrade Bamboo Server

Bamboo 5.9 will no longer be supported after June 12, 2017. What does this mean? As part of our End of Life policy, Atlassian supports major versions for two years after the first major iteratio...

1,068 views 0 5
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot