Search code examples
dockergithubdocker-composetravis-ci

Why is Docker image is not appearing on Docker Hub after being pushed from Travis CI


I tried to push my docker images from Travis CI to docker hub but its not appearing on my docker hub. All builds were successful

sudo: required
language: generic
services: 
    - docker

before_install:
    - docker build -t nedstark/docker-tcwlmd -f restful/Dockerfile.dev .

# script:
#     - docker run nedstark/docker-tcwlmd coverage run -m unittest discover restful/

after_success:
    - docker build -t nedstark/server ./restful
    - docker build -t nedstark/worker ./worker
    - docker build -t nedstark/nginx ./nginx
    #Log in to docker Cli
    - echo "$DOCKER_PASSWORD" | docker login -u "DOCKER_ID" --password-stdin
    #Take these images and push them to docker hub
    - docker push nedstark/tcwl-server
    - docker push nedstark/tcwl-worker
    - docker push nedstark/tcwl-nginx

Solution

    1. Create an Access-Token via the Docker Hub Settings --> Security

    2. Add DOCKER_USERNAME and DOCKER_PASSWORD into your Travis-CI Build settings as environment variables. Make sure the DOCKER_PASSWORD is the generated Access-Token from step 1

    3. in the .travis.yml add:

      docker login -u "$DOCKER_USERNAME" -p "$DOCKER_PASSWORD" docker.io
      

    This should be able to trigger a build and push the Docker Image to the Docker Hub.