Playing With Docker Container - Commands
Playing With Docker Container - Commands
Playing With Docker Container - Commands
For Containers :
docker stop $(docker ps -qa)
docker rm $(docker ps -qa)
For Images :
docker rmi $(docker images -qa)
docker images
docker rmi -f b00ea124ed62 529165268aa2 0c45f7936948
docker images
Docker run :
--privileged
$ docker run -t -i --rm ubuntu bash
root@bc338942ef20:/# mount -t tmpfs none /mnt
mount: permission denied
-w
$ docker run -w /path/to/dir/ -i -t ubuntu pwd
The -w lets the command being executed inside directory given, here
/path/to/dir/.
Note : If the path does not exist it is created inside the container.
docker run -itd -p 8050:80 -m 1GB --name nginx3 -w
//usr//share//nginx//html -v c:/html:/usr/share/nginx/html nginx
$ docker run --env VAR1=value1 --env VAR2=value2 ubuntu env | grep VAR
VAR1=value1
VAR2=value2
Limiting Memory
$ docker run -d -p 8081:80 --memory=20m --memory-swap=20m nginx
$ docker container run -d --memory-reservation=250m --name mymem1
alpine:3.8 sleep 3600
Limiting CPU
--cpus
Docker 1.13 and higher:
$ docker run -it --cpus=".5" ubuntu /bin/bash
docker stats :
Copy :
Logs :
$ docker logs 779eb8148aa7 --follow