AuthZRequest for POST /containers/create... authorization denied

I'm having a Java unit test, which ultimately uses Spotify's Docker Client. It fails to create the Docker container on Bitbucket Pipelines, as follows:

msg="Pipelines plugin request authorization." allowed=true method=GET plugin=pipelines uri=/info
msg="Pipelines plugin request authorization." allowed=true method=GET plugin=pipelines uri=/version
msg="Pipelines plugin request authorization." allowed=true method=GET plugin=pipelines uri="/images/json?filters=%7B%22dangling%22%3A%5B%22false%22%5D%7D"
msg="Pipelines plugin request authorization." allowed=true method=POST plugin=pipelines uri="/images/create?fromImage=mdillon/postgis&tag=9.5-alpine"
msg="Pipelines plugin request authorization." allowed=false method=POST plugin=pipelines uri=/containers/create
msg="AuthZRequest for POST /containers/create returned error: authorization denied by plugin pipelines: Command not supported."
2018-01-24 22:35:09,458 WARN received SIGTERM indicating exit request

As this works fine on my local machine, I'm a little puzzled of what's so different about Pipelines?

I'm not mounting in any volumes, so I don't think it's this issue.

2 answers

1 accepted

As it turns out, for this to work, I need to include the API version of the Docker server, i.e.:

DockerClient dockerClient = ...;
dockerClient.apiVersion = "1.29";

Not quite that simple (in the code), since DockerClient is immutable, but conceptually this was it.

I am trying to create a container for testing but I get the same error you reported.  I added the version to the call too but it does not work. Could you please, add the call that works as you did below? just to compare the headers of the POST call

 My call is as simple as

 

>> "POST /v1.29/containers/create HTTP/1.1[\r][\n]"
>> "Accept: application/json[\r][\n]"
>> "Content-Type: application/json[\r][\n]"
>> "User-Agent: Jersey/2.23.1 (Apache HttpClient 4.5)[\r][\n]"
>> "Transfer-Encoding: chunked[\r][\n]"
>> "Host: localhost:2375[\r][\n]"
>> "Connection: Keep-Alive[\r][\n]"
>> "Accept-Encoding: gzip,deflate[\r][\n]"
>> "[\r][\n]"
>> "81[\r][\n]"
>> "{"Image":"redis","Volumes":{},"ExposedPorts":{},"HostConfig":{"NetworkMode":"default","Privileged":false,"PublishAllPorts":true}}[\r][\n]"
>> "0[\r][\n]"
>> "[\r][\n]"
<< "HTTP/1.1 403 Forbidden[\r][\n]"
<< "Content-Type: application/json[\r][\n]"
<< "Date: Thu, 15 Feb 2018 10:42:44 GMT[\r][\n]"
<< "Content-Length: 79[\r][\n]"
<< "[\r][\n]"
<< "{"message":"authorization denied by plugin pipelines: Command not supported."}[\n]"

 

thanks in advance.  

Is Bitbucket still at 1.29? You can check with:

docker version --format "{{.Server.APIVersion}}

If Bitbucket were to be using a different (newer) API version, setting it to 1.29 would give you the same problem situation as originally.

This command is also what I use to parameterize the fix that I described, so that it's not hard-coded at 1.29:

export DOCKER_SERVER_API_VERSION="$(docker version --format "{{.Server.APIVersion}}")"

Here is more information:

>> "POST /containers/create HTTP/1.1[\r][\n]"
>> "Accept: application/json[\r][\n]"
>> "Content-Type: application/json[\r][\n]"
>> "User-Agent: Jersey/2.19 (Apache HttpClient 4.5.2)[\r][\n]"
>> "Transfer-Encoding: chunked[\r][\n]"
>> "Host: localhost:2375[\r][\n]"
>> "Connection: Keep-Alive[\r][\n]"
>> "Accept-Encoding: gzip,deflate[\r][\n]"
>> "[\r][\n]"
>> "ad[\r][\n]"
>> "{"Env":["POSTGRES_USER=test","POSTGRES_PASSWORD=test","POSTGRES_DB=test"],"Image":"mdillon/postgis:9.5-alpine","NetworkDisabled":false,"HostConfig":{"PublishAllPorts":true}}[\r][\n]"
>> "0[\r][\n]"
>> "[\r][\n]"
<< "HTTP/1.1 403 Forbidden[\r][\n]"
<< "Content-Type: application/json[\r][\n]"
<< "Date: Thu, 25 Jan 2018 02:10:45 GMT[\r][\n]"
<< "Content-Length: 79[\r][\n]"
<< "[\r][\n]"
<< "{"message":"authorization denied by plugin pipelines: Command not supported."}[\n]"
<< HTTP/1.1 403 Forbidden
<< Content-Type: application/json
<< Date: Thu, 25 Jan 2018 02:10:45 GMT
<< Content-Length: 79

Should I contact something else than "localhost", seems not?

Evidently this was not an answer, just an elaboration of the question, but please see my "accepted" answer for the real solution.

Suggest an answer

Log in or Join to answer
Community showcase
Piotr Plewa
Published Dec 27, 2017 in Bitbucket

Recipe: Deploying AWS Lambda functions with Bitbucket Pipelines

Bitbucket Pipelines helps me manage and automate a number of serverless deployments to AWS Lambda and this is how I do it. I'm building Node.js Lambda functions using node-lambda&nbsp...

710 views 0 4
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