![]() |
VOOZH | about |
Logging in to Docker is the first step before pulling or pushing images to Docker Hub. By authenticating with your Docker Hub credentials, you can securely access both public and private repositories.
Windows and macOS:
Ubuntu:
For Ubuntu based distributions you can use the following commands.
#Check Docker's official documentation for further info
# Add Docker's official GPG key:
sudo apt-get update
sudo apt-get install ca-certificates curl
sudo install -m 0755 -d /etc/apt/keyrings
sudo curl -fsSL https://download.docker.com/linux/ubuntu//gpg -o /etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyrings/docker.asc
# Add the repository to Apt sources:
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu/ \
$(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update
#install latest version of docker packages
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
#verify docker engine installation is successful
docker --version
For other distributions please refer to the official docker documentation.
To verify docker's installation open a terminal and run `docker --version`
docker --versionTo interact with Docker Hub, you first need to create an account and log in via the command line.
Step 1: Open a terminal
Step 2: use the `docker login` command
docker loginStep 3: Enter your username and password when prompted
username:<enter your username>
password: <enter your password>
Step 4: On Successful login you will be prompted with: `login succeeded`
login succeededdocker search <image_name>2. Pull the image using `docker pull`
docker pull <image_name>Example:
A `dockerfile` contains instructions for building a Docker image. Example:
FROM ubuntu:latest
RUN apt-get update && apt-get install -y python3
COPY . /app
WORKDIR /app
CMD ["python3", "app.py"]
build the docker image using the following command:
docker build -t <your_image_name> .docker tag <your_image_name> <your_dockerhub_username>/<repository_name>:<tag>You can use docker push to push your image to docker hub as follows
docker push <your_dockerhub_username>/<repository_name>:<tag>Upon successful execution you'll find your image uploaded to docker hub.