My project has very specific requirements to be able to build and deploy. How do I do this?
Using this as an example repository: https://github.com/mark-adams/docker-chromium-xvfb, there are some steps required to create your own docker image.
Well, sign up here =) https://hub.docker.com/
One way is to use Docker toolbox: https://www.docker.com/products/docker-toolbox
Example file here: https://github.com/mark-adams/docker-chromium-xvfb/blob/master/images/base/Dockerfile
#Some smart base image FROM debian:jessie # Whatever you need more than what is on the base image required by your project RUN apt-get update && apt-get install -y xvfb chromium ADD xvfb-chromium /usr/bin/xvfb-chromium RUN ln -s /usr/bin/xvfb-chromium /usr/bin/google-chrome RUN ln -s /usr/bin/xvfb-chromium /usr/bin/chromium-browser
In the same directory as you have your Dockerfile, run command:
docker build -t yourdockerusername/imagename .
Run command
docker push yourdockerusername/imagename
As documented here: https://confluence.atlassian.com/display/BITBUCKET/Use+Docker+images+as+build+environments+in+Bitbucket+Pipelines
You can use your image on a top level as well as on a specific step like this.
image: yourdockerusername/imagename pipelines: default: - step: script: - echo "This script runs on all branches that don't have any specific pipeline assigned in 'branches'." branches: master: - step: script: - echo "This script runs only on commit to the master branch." feature/*: - step: image: yourdockerusername/imagename # This step uses its own image script: - echo "This script runs only on commit to branches with names that match the feature/* pattern."
Enjoy Bitbucket Pipelines!
I cannot push. I get an error:
> An image does not exist locally with the tag
even though I built it.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Kind of want to kiss you for this post. thanks so much! <3
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@sbirgisson Thank you so much. It helped me a lot. But i have a question, how can i cache dockerhub image in pipeline. Cause it always pulls from dockerhub for each step, which means i have three steps and my docker image size is `600MB`. So it pulls that image each and everytime.
I want to cache this docker image, so the next step wont need to pull again. Any solution for this?
Thanks.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
one should note that you should be logged in for STEP 5:
docker login -u {{USERNAME}} -p {{PASSWORD}}
where
{{USERNAME}} is to be replaced by your actual hub.docker.com user name
{{PASSWORD}} is to be replaced by your actual hub.docker.com password
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
If you want to build a docker image with packer, this is an example by Alan Parkinson:
https://bitbucket.org/hindsightsoftwareltd/docker-for-pipelines
from
https://www.hindsightsoftware.com/blog/building-docker-images-for-bitbucket-pipelines-using-packer
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
In case anyone is still having this issue, I was able to resolve mine by changing the login command to use short flags instead of full parameters
replace --username with -u and --password with -p as shown below
docker login -u $DOCKER_USERNAME -p $DOCKER_USERNAME
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Have you tried tagging it with the fully qualified name of the repository and then pushing it?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
For weird reason, the forum won't let me post my question; so posting a link to my question in StackOverflow:
This issue is really puzzling and I wonder if anyone can drop in an insight. Thanks!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
This issue applies to Bitbucket pipelines. I have seen the other related questions, and frankly the Bitbucket yaml and Dockerfile scripts work great when directly executed in bash terminal.
Just when executing the pipeline, it fails, right after successful login.
Here is my Yaml file:
# enable Docker for the repository options: docker: true # Start the pipeline pipelines: default: - step: script: # Name the image and create a docker image - docker build -t "my_docker_id/my_app:latest" . - docker login --username $DOCKER_HUB_USERNAME --password $DOCKER_HUB_PASSWORD - docker push my_docker_id/my_app:latest
And my Dockerfile looks like:
FROM ubuntu:latest
# Install Python and related tools
RUN apt-get update && apt-get install -y --no-install-recommends apt-utils
RUN apt-get -y upgrade
RUN apt-get install -y python3
RUN apt-get install -y python3-pip
RUN pip3 install --upgrade pip
# Now use Pip to install Flask
RUN pip3 install flask
# Set the working directory to Ubuntu user home
WORKDIR /home/ubuntu
# Then copy the website folder to home folder
COPY . /home/ubuntu
The docker login succeeds:
docker login --username $DOCKER_HUB_USERNAME --password $DOCKER_HUB_PASSWORD<1s Login Succeeded
The pipeline fails on:
docker push my_docker_id/my_app:latest
Failed with:
+ docker push cbrodock/corpsite:latest The push refers to a repository [docker.io/cbrodock/corpsite] bdca855fbe4a: Preparing d147d767df7b: Preparing f6aad432f761: Preparing 0da658ad5264: Preparing 84e11e4ededf: Preparing 50fd25888dad: Preparing 2cb0a11f65e0: Preparing ad8ba289abb4: Preparing 33f1a94ed7fc: Preparing b27287a6dbce: Preparing 47c2386f248c: Preparing 2be95f0d8a0c: Preparing 2df9b8def18a: Preparing 50fd25888dad: Waiting 47c2386f248c: Waiting 2cb0a11f65e0: Waiting 33f1a94ed7fc: Waiting 2df9b8def18a: Waiting b27287a6dbce: Waiting 2be95f0d8a0c: Waiting ad8ba289abb4: Waiting unauthorized: authentication required
If I execute the same exact steps in my bash terminal on MacOS, they execute fine and push succeeds.
Any ideas?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Cannot DOCKER PUSH to hub. I have detailed the issue here >> https://stackoverflow.com/questions/44146389/bitbucket-pipelines-docker-unauthorized-authentication-required-docker-push
Will appreciate a response.
Copy pasting the issue here:
This issue applies to Bitbucket pipelines. I have seen the other related questions, and frankly the Bitbucket yaml and Dockerfile scripts work great when directly executed in bash terminal.
Just when executing the pipeline, it fails, right after successful login.
Here is my Yaml file:
# enable Docker for the repository
options:
docker: true
# Start the pipeline
pipelines:
default:
- step:
script: # Name the image and create a docker image
- docker build -t "my_docker_id/my_app:latest" .
- docker login --username $DOCKER_HUB_USERNAME --password $DOCKER_HUB_PASSWORD
- docker push my_docker_id/my_app:latest
And my Dockerfile looks like:
FROM ubuntu:latest # Install Python and related tools RUN apt-get update && apt-get install -y --no-install-recommends apt-utils RUN apt-get -y upgrade RUN apt-get install -y python3 RUN apt-get install -y python3-pip RUN pip3 install --upgrade pip # Now use Pip to install Flask RUN pip3 install flask # Set the working directory to Ubuntu user home WORKDIR /home/ubuntu # Then copy the website folder to home folder COPY . /home/ubuntu
The docker login succeeds:
docker login --username $DOCKER_HUB_USERNAME --password $DOCKER_HUB_PASSWORD<1s Login Succeeded
The pipeline fails on:
docker push my_docker_id/my_app:latest
With the following error:
+ docker push cbrodock/corpsite:latest The push refers to a repository [docker.io/cbrodock/corpsite] bdca855fbe4a: Preparing d147d767df7b: Preparing f6aad432f761: Preparing 0da658ad5264: Preparing 84e11e4ededf: Preparing 50fd25888dad: Preparing 2cb0a11f65e0: Preparing ad8ba289abb4: Preparing 33f1a94ed7fc: Preparing b27287a6dbce: Preparing 47c2386f248c: Preparing 2be95f0d8a0c: Preparing 2df9b8def18a: Preparing 50fd25888dad: Waiting 47c2386f248c: Waiting 2cb0a11f65e0: Waiting 33f1a94ed7fc: Waiting 2df9b8def18a: Waiting b27287a6dbce: Waiting 2be95f0d8a0c: Waiting ad8ba289abb4: Waiting unauthorized: authentication required
If I execute the same exact steps in my bash terminal on MacOS, they execute fine and push succeeds.
Any ideas?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello,
I think you should change your login line to this
docker login -u $DOCKER_USERNAME -p $DOCKER_USERNAME
I had similar issue with using --username and --password
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Fighting with same issue, just can not understand what is wrong and where
I did managed to build and publish following docker image:
FROM node RUN mkdir /code WORKDIR /code COPY package.json /code RUN npm install -s
Idea behind it is to not install node dependencies each time
But after trying to use my image i got "sh: 1: webpack: not found"
I can run it locally like so: docker run --rm -v %cd%/dist:/code/dist foo/bar npm run dist -s
and all works as expected, hope somebody can clarify what is happening
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.