mayurwaghmode / use-to-commands

1 stars 0 forks source link

Docker commands #3

Open mayurwaghmode opened 1 year ago

mayurwaghmode commented 1 year ago

Pull image docker pull <imageName>

Build an image from a specified docker file: docker build <path to the dockerfile>

List all images: docker images

Remove an image: docker rmi <imageID>

Save an image into a tar file: docker save <imageName> > <tarFile>

Load an Image from a tar file: docker load -i <tarFile>

mayurwaghmode commented 1 year ago

Related to containers:

List running containers: docker ps

List all containers: docker ps -a

Access a running container: docker exec -it <container id> bash

Remove all stopped containers: docker container prune

Delete all running and stopped containers: docker container rm -f $(docker ps -aq)

Start a stopped container: docker start <containerName>

Restart (stop + start) the container: docker restart ID

Rename a container: docker rename <containerName> <newContainerName>

Show all modified files in a container: docker diff <containerName>

mayurwaghmode commented 1 year ago

Related to the system and volumes:

Clean the system (meta images and stopped containers): docker system prune = docker container prune + docker image prune

Remove volumes: docker volume prune

mayurwaghmode commented 1 year ago

Docker terms- https://medium.com/faun/top-10-docker-interview-questions-how-many-questions-can-you-answer-correctly-beginners-part-i-47b667bed137

mayurwaghmode commented 1 year ago

Publishing Container to Quay

Login to Quay.io

docker login quay.io (will now be prompted for username + password)

Get your containerID

docker ps -l

Tag that container by containerId

docker commit <containerId> quay.io/<myUsername>/<myRegistry>

Now publish it to Quay.io

docker push quay.io/<myUsername>/<myRegistry>