Docker Push Fails with Permission Denied

I have been trying to push one of my image that I build using Travis CI, but I notice that the push kind of fails. Here is the log output for my build pipeline:

> Pushing image plant-simulator to repository hub.docker.com The push
> refers to repository [**docker.io**/joesan/plant-simulator] f790cd843a8c:
> Preparing 884e60053187: Preparing a4ec5ee85199: Preparing
> d5ead368c960: Preparing 4fe15f8d0ae6: Preparing denied: requested
> access to the resource is denied The push refers to repository
> [docker.io/joesan/plant-simulator] f790cd843a8c: Preparing
> 884e60053187: Preparing a4ec5ee85199: Preparing d5ead368c960:
> Preparing 4fe15f8d0ae6: Preparing

What I don#t understand is that from where is this repository url being populated? It should have been hub.docker.com instead of docker.io which is the reason for the error, but I’m not sure who is providing this information to the docker runtime in Travis. Here is the command that I use to log in to Docker (as a script in my Travis yml file)

echo “$DOCKER_REGISTRY_PASSWORD” | docker login -u
“$DOCKER_REGISTRY_USERNAME” –password-stdin;

Source: StackOverflow