- Download image
- Run a container with exposed ports
- Exit container
- Continue by starting the exited container
Pro tip: Add this to your aliases(.bashrc,.zshrc):
alias dps="echo -e 'Currently up and running:\n' && docker ps && echo -e '\n'"
alias dpsa="echo -e 'Currently up and running:\n' && docker ps && echo -e '\nAvailable containers:\n' && docker ps -a && echo -e'\n'"
alias dcup="docker-compose up"
alias dcdown="docker-compose down"
alias dstart="docker start"
alias dstop="docker stop"
alias dimages="docker images"
alias dcontainers="docker ps -a"
alias dattach="docker attach"
alias dlogs="docker logs"
alias dkillall="docker stop $(docker ps -aq) && docker rm $(docker ps -aq)" # containers only
alias dnuke="docker stop $(docker ps -aq) && docker rm $(docker ps -aq) && docker rmi -f $(docker -aq)" # images and containers
alias getip="ifconfig | grep inet"
dexec(){
docker exec -it $1 /bin/bash
}
systemctl enable docker.service
systemctl start docker.service
docker pull _IMAGENAME_
docker run -p _HOSTPORT_:_CONTAINERPORT_ _IMAGE_
docker run -P _IMAGE_
docker images
docker ps -a
docker run _IMAGE_
docker stop _CONTAINER_ID_
docker start _CONTAINER_ID_
docker rm _CONTAINER_ID_
docker logs _CONTAINER_ID_
docker ps -a | grep Exit | cut -d ' ' -f 1 | xargs docker rm
alternatively,
docker [image/container/volume/network] prune (-a)
docker stop $(docker ps -aq) && docker rm $(docker ps -aq)
docker-machine env default
_run the last line as mentioned. e.g:_
eval $("C:\Program Files\Docker Toolbox\docker-machine.exe" env default)
docker-machine ls
docker exec -it CONTAINER_NAME bash -l
docker-compose up
docker-compose down
docker-compose stop
docker-compose start
docker-compose ps
docker-compose images
docker build -f "path/to/dockerfile.local" --pull --no-cache
docker rmi $(docker images -f "dangling=true" -q)
docker exec -it _CONTAINER_NAME_ bash
ping _SERVICE_
curl -s _SERVICE_:_PORT_ >/dev/null && echo Success. || echo Fail.