Services/Docker: Difference between revisions

From Fundamental Ramen
Jump to navigation Jump to search
Line 52: Line 52:
= Problems on Windows =
= Problems on Windows =


== Don't use GitBash if run with -v (--volume) option. ==
== Using volume in GitBash ==


While run docker under GitBash, path would be replace unexpectedly.
Works.
 
Such as the following example, mount point "/vol" was replaced by "\Programs Files\Git\vol".
 
<pre>
/ # winpty docker run --name sandbox0 \
  -v /C/Users/Raymond/repos/twnews:/vol \
  -it alpine:3.11
 
/ # ls -l
total 56
drwxrwxrwx    1 root    root            0 Sep 30 07:29 \Program Files\Git\vol
drwxr-xr-x    2 root    root          4096 Apr 23 06:25 bin
drwxr-xr-x    5 root    root          360 Sep 30 08:06 dev
drwxr-xr-x    1 root    root          4096 Sep 30 08:06 etc
drwxr-xr-x    2 root    root          4096 Apr 23 06:25 home
drwxr-xr-x    5 root    root          4096 Apr 23 06:25 lib
drwxr-xr-x    5 root    root          4096 Apr 23 06:25 media
drwxr-xr-x    2 root    root          4096 Apr 23 06:25 mnt
drwxr-xr-x    2 root    root          4096 Apr 23 06:25 opt
dr-xr-xr-x  153 root    root            0 Sep 30 08:06 proc
drwx------    1 root    root          4096 Sep 30 08:06 root
drwxr-xr-x    2 root    root          4096 Apr 23 06:25 run
drwxr-xr-x    2 root    root          4096 Apr 23 06:25 sbin
drwxr-xr-x    2 root    root          4096 Apr 23 06:25 srv
dr-xr-xr-x  12 root    root            0 Sep 30 08:06 sys
drwxrwxrwt    2 root    root          4096 Apr 23 06:25 tmp
drwxr-xr-x    7 root    root          4096 Apr 23 06:25 usr
drwxr-xr-x  12 root    root          4096 Apr 23 06:25 var
</pre>


<pre>
<pre>
Line 89: Line 60:
winpty docker run --name sandbox0 -v 'C:\Users\Raymond\repos\twnews':/vol -it alpine:3.11
winpty docker run --name sandbox0 -v 'C:\Users\Raymond\repos\twnews':/vol -it alpine:3.11
</pre>
</pre>
Unexpected error.


<pre>
<pre>
Line 94: Line 67:
docker: Error response from daemon: The system cannot find the file specified.
docker: Error response from daemon: The system cannot find the file specified.
See 'docker run --help'.
See 'docker run --help'.
</pre>
Mount point "/vol" was replaced by "\Programs Files\Git\vol".


<pre>
$ winpty docker run --name sandbox0 -v "/C/Users/Raymond/repos/twnews":/vol -it alpine:3.11
$ winpty docker run --name sandbox0 -v "/C/Users/Raymond/repos/twnews":/vol -it alpine:3.11
/ # ls -l
/ # ls -l

Revision as of 08:54, 30 September 2020

Clean Docker

TODO Command
Remove exited containers
docker rm $(docker ps -f 'status=exited' -q)

sudo docker rm $(sudo docker ps -f 'status=exited' -q)
Remove unused images
docker rmi $(docker images -f "dangling=true" -q)

sudo docker rmi $(sudo docker images -f "dangling=true" -q)
run and start it again
docker run --name sandbox0 \
  --volume a:b \
  -it alpine:3.11
docker start -i sandbox0
Make apt faster
FROM ubuntu:20.04

RUN sed -i 's/\(archive\|security\).ubuntu.com/free.nchc.org.tw/' /etc/apt/sources.list
RUN apt update
# 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
Run
# 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

Problems on Windows

Using volume in GitBash

Works.

winpty docker run --name sandbox0 -v "C:\Users\Raymond\repos\twnews":/vol -it alpine:3.11
winpty docker run --name sandbox0 -v 'C:\Users\Raymond\repos\twnews':/vol -it alpine:3.11

Unexpected error.

$ winpty docker run --name sandbox0 -v C:\Users\Raymond\repos\twnews:/vol -it alpine:3.11
docker: Error response from daemon: The system cannot find the file specified.
See 'docker run --help'.

Mount point "/vol" was replaced by "\Programs Files\Git\vol".

$ winpty docker run --name sandbox0 -v "/C/Users/Raymond/repos/twnews":/vol -it alpine:3.11
/ # ls -l
total 56
drwxrwxrwx    1 root     root             0 Sep 30 07:29 \Program Files\Git\vol
drwxr-xr-x    2 root     root          4096 Apr 23 06:25 bin
drwxr-xr-x    5 root     root           360 Sep 30 08:46 dev
drwxr-xr-x    1 root     root          4096 Sep 30 08:46 etc
drwxr-xr-x    2 root     root          4096 Apr 23 06:25 home
drwxr-xr-x    5 root     root          4096 Apr 23 06:25 lib
drwxr-xr-x    5 root     root          4096 Apr 23 06:25 media
drwxr-xr-x    2 root     root          4096 Apr 23 06:25 mnt
drwxr-xr-x    2 root     root          4096 Apr 23 06:25 opt
dr-xr-xr-x  154 root     root             0 Sep 30 08:46 proc
drwx------    1 root     root          4096 Sep 30 08:46 root
drwxr-xr-x    2 root     root          4096 Apr 23 06:25 run
drwxr-xr-x    2 root     root          4096 Apr 23 06:25 sbin
drwxr-xr-x    2 root     root          4096 Apr 23 06:25 srv
dr-xr-xr-x   12 root     root             0 Sep 30 08:46 sys
drwxrwxrwt    2 root     root          4096 Apr 23 06:25 tmp
drwxr-xr-x    7 root     root          4096 Apr 23 06:25 usr
drwxr-xr-x   12 root     root          4096 Apr 23 06:25 var

Problems on Synology DSM

TODO