docker build -t username/repository:tag .
docker login my.registry.com:8000
docker tag <image> username/repository:tag
docker push username/repository:tag
docker pull username/repository:tag
docker run username/repository:tag
docker ps
docker ps -all
docker container ls # List all running containers
docker container ls -a # List all containers, even those not running
docker container stop <hash> # Gracefully stop the specified container
docker container kill <hash> # Force shutdown of the specified container
docker rm <container>
docker container rm <hash> # Remove specified container from this machine
docker container rm $(docker container ls -a -q) # Remove all containers
docker images
docker rmi <image>
docker image ls -a # List all images on this machine
docker image rm <image id> # Remove specified image from this machine
docker image rm $(docker image ls -a -q) # Remove all images from this machine
docker run --rm -it --name my_container -p 4000:80 -v ~/dev:/code username/repository:tag /bin/bash
Command |
Purpose |
Example |
FROM |
First non-comment instruction in Dockerfile |
FROM ubuntu |
COPY |
Copies mulitple source files from the context to the file system of the container at the specified path |
COPY .bash_profile /home |
ENV |
Sets the environment variable |
ENV HOSTNAME=test |
RUN |
Executes a command |
RUN apt-get update |
CMD |
Defaults for an executing container |
CMD ["/bin/echo", "hello world"] |
EXPOSE |
Informs the network ports that the container will listen on |
EXPOSE 8093 |