|
|
| Line 1: |
Line 1: |
| == Clean Docker == | | == Clean Images == |
|
| |
|
| {| class="wikitable"
| | sudo docker image prune |
| ! TODO || Command
| |
| |-
| |
| | Run debian image on Windows ||
| |
| <syntaxhighlight lang="bash">
| |
| # Git Bash
| |
| winpty docker run --name=debian0 -it debian:12
| |
| | |
| # Power Shell
| |
| docker run --name=debian0 -it debian:12
| |
| </syntaxhighlight>
| |
| |-
| |
| | Open shell of running container ||
| |
| <syntaxhighlight lang="bash">
| |
| docker exec -it mwdev-mediawiki-1 /bin/bash
| |
| </syntaxhighlight>
| |
| |-
| |
| | Copy file from running container ||
| |
| <syntaxhighlight lang="bash">
| |
| docker cp mwdev-mediawiki-1:/var/www/data/my_wiki.sqlite . | |
| </syntaxhighlight>
| |
| |-
| |
| | Build image ||
| |
| <syntaxhighlight lang="bash">
| |
| docker build .
| |
| docker build -t gdtile:2.1 .
| |
| docker tag c8abdb693116 gdtile:2.1
| |
| </syntaxhighlight>
| |
| |-
| |
| | Remove exited containers ||
| |
| <syntaxhighlight lang="bash">
| |
| docker rm $(docker ps -f 'status=exited' -q)
| |
| | |
| sudo docker rm $(sudo docker ps -f 'status=exited' -q)
| |
| </syntaxhighlight>
| |
| |-
| |
| | Remove unused images ||
| |
| <syntaxhighlight lang="bash">
| |
| docker rmi $(docker images -f "dangling=true" -q)
| |
| | |
| sudo docker rmi $(sudo docker images -f "dangling=true" -q)
| |
| </syntaxhighlight>
| |
| |-
| |
| | run and start it again ||
| |
| <syntaxhighlight lang="docker">
| |
| docker run --name sandbox0 \
| |
| --volume a:b \
| |
| -it alpine:3.11
| |
| docker start -i sandbox0
| |
| </syntaxhighlight>
| |
| |-
| |
| | Make apt faster ||
| |
| <syntaxhighlight lang="docker">
| |
| FROM ubuntu:20.04
| |
| | |
| RUN sed -i 's/\(archive\|security\).ubuntu.com/free.nchc.org.tw/' /etc/apt/sources.list
| |
| RUN apt update
| |
| </syntaxhighlight>
| |
| | |
| <syntaxhighlight lang="bash">
| |
| # In host
| |
| docker run -it ubuntu:20.04
| |
| # In container
| |
| sed -i 's/\(archive\|security\).ubuntu.com/free.nchc.org.tw/' /etc/apt/sources.list
| |
| apt update
| |
| </syntaxhighlight>
| |
| |-
| |
| | Run ||
| |
| <syntaxhighlight lang="docker">
| |
| # Mapping directory on Windows, do not use ~
| |
| docker run -v C:\Users\User\repos\something:/docroot -it someimage bash
| |
| docker run -v %USERPROFILE%\repos\webserv:/docroot -it webserv-compose_web bash
| |
| </syntaxhighlight>
| |
| |-
| |
| | test ||
| |
| <syntaxhighlight lang="docker">
| |
| docker ps --size --all
| |
| </syntaxhighlight>
| |
| |-
| |
| | logs ||
| |
| <syntaxhighlight lang="docker">
| |
| docker ps logs -ft container
| |
| </syntaxhighlight>
| |
| |}
| |