Logging into Docker Registry
In this recipe, we will write a task to log in to Docker Registry. If we are using a private registry and want to push or pull Docker images, we first need to log in to that Docker Registry.
In the following task we will use Docker Hub as the Docker Registry. We will be logging into Docker Hub and will push an image to Docker Hub's private repository.
How to do it…
- Let's define a task for logging into Docker Registry:
- name: Log into DockerHub docker_login: username: vikas17a password: XXXXXXXXX email: [email protected] tags: - recipe6
- Let's try to push an image to Docker Hub's private repository using the login:
- name: Push image to Dockerhub docker_image: repository: vikas17a/cookbook name: cookbook tag: firstbuilt path: docker_files/ push: yes tags: - recipe6
How it works…
In step 1, we used the Ansible module docker_login
to log in to a Docker Registry, in our case, Docker Hub. We should note that docker_login
...