Docker 101

(add “sudo” before the commands if needed)

*frequently used docker commands, test them out*
docker ps
docker run -it Name
docker images
docker start ContainerID
docker attach ContainerID

*rename a docker image*
docker tag ContainerID  NewName
docker rmi OldName

*delete an image whose tag is <none>”
docker images –digests
docker rmi OldName@digests

*copy a file from host to container*
docker cp foo.txt ContainerID:/foo.txt

*copy a file from Docker container to host*
docker cp ContainerID:/foo.txt foo.txt

*when you use docker attach, the container does not respond, try*:  docker exec -it ContainerName bash

*exit docker without kill it*
ctrl+p, ctrl+q

*exit docker and kill it”
from the container: exit
or start from another shell: docker stop ContainerID

*save the files and settings of the docker in a new image, stored locally*
docker commit ContainerID NewName

*push docker image to docker hub*
docker tag ContainerID NewName
docker login
docker push NewName
docker logout

*pull docker image from docker hub*
docker pull DockerhubID/NewName
docker images

Leave a Reply

Your email address will not be published. Required fields are marked *