Docker Cheatsheet, List of Basic docker commands
$ docker run <containerId> #run docker container, first checks locally, if not found pull from remote repository
$ docker stop <containerId> #stop docker container
$ docker ps -a # list all the containers
$ docker rm <containerId> # delete docker container
$ docker rm $(docker ps -a -q -f status=exited) #deleted all the exited docker container
$ docker commit <container-id> <image-name>
$ docker search <imageName> #same as git repo
$ docker pull <imageName> #same as git pull
list network
$ docker network ls
create network
$docker network create <networkName>
inspect docker network
$ docker network inspect <networkName>
run container and attach to network
$docker run -it --net=<networkName> <containerName>
run multiple container in same network
$docker run -it --net=bridge <containerName>
$docker run -it --net=container:<containerName> <containerName>
create a docker file, first add maven docker plugin from https://github.com/spotify/dockerfile-maven in pom.xml
$mvn install dockerfile:build
run the above image as container
$ docker run -p <spring-boot-app-serverport>:<local-machine-port> -t <containername>
with command arguments
$ docker run -e "server.profile=dev" -p 8080:8080 -t <containerName>
To run docker without sudo first add docker as group in Ubuntu
$ sudo groupadd docker
Add user to this group
$ sudo gpasswd -a <username> docker
Restart docker
$ sudo service docker restart
Log out and Log in, now we can run the docker command without sudo
A curated list of Docker resources and projects
https://github.com/veggiemonk/awesome-docker
$ docker run <containerId> #run docker container, first checks locally, if not found pull from remote repository
$ docker stop <containerId> #stop docker container
$ docker ps -a # list all the containers
$ docker rm <containerId> # delete docker container
$ docker rm $(docker ps -a -q -f status=exited) #deleted all the exited docker container
$ docker commit <container-id> <image-name>
$ docker search <imageName> #same as git repo
$ docker pull <imageName> #same as git pull
list network
$ docker network ls
create network
$docker network create <networkName>
inspect docker network
$ docker network inspect <networkName>
run container and attach to network
$docker run -it --net=<networkName> <containerName>
run multiple container in same network
$docker run -it --net=bridge <containerName>
$docker run -it --net=container:<containerName> <containerName>
create a docker file, first add maven docker plugin from https://github.com/spotify/dockerfile-maven in pom.xml
$mvn install dockerfile:build
run the above image as container
$ docker run -p <spring-boot-app-serverport>:<local-machine-port> -t <containername>
with command arguments
$ docker run -e "server.profile=dev" -p 8080:8080 -t <containerName>
To run docker without sudo first add docker as group in Ubuntu
$ sudo groupadd docker
Add user to this group
$ sudo gpasswd -a <username> docker
Restart docker
$ sudo service docker restart
Log out and Log in, now we can run the docker command without sudo
A curated list of Docker resources and projects
https://github.com/veggiemonk/awesome-docker
Comments
Post a Comment