-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdocker_note
85 lines (51 loc) · 2.21 KB
/
docker_note
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
DOCKER NOTE
--- For Creating Docker file
1. Run a linux command
use: RUN <ubuntu command>
2. ADD a FOLDER to THE DOCKE:
use: ADD <folder path>
3. Change docker directory
use: WORKDIR <folder path>
4. Clone github
use: git clone https://<usermname>:<password>@bitbucket.org/verysmartdonkey/base-detector.git
--- Build Image
docker build -t <repository_name>:<tag> .
-- IF you use .tar file from another person
-- Load docker .tar file
docker load -i <file-name>.tar
-- Build container
docker run -it --runtime=nvidia --name <name of the container> -v <host folder path>:<docker folder path> --network=host --env="DISPLAY" --volume="$HOME/.Xauthority:/root/.Xauthority:rw" --entrypoint /bin/bash <image_name>
---- Explanation:
1. Mount a FOLDER to THE DOCKER:
-v <host folder path>:<docker folder path>
2. SET GUI in DOCKER
--network=host --env="DISPLAY" --volume="$HOME/.Xauthority:/root/.Xauthority:rw"
---- Example: sudo docker run -it --runtime=nvidia --name opencv_nodeflux_project3 -v "$(pwd)":/home --network=host --env="DISPLAY" --volume="$HOME/.Xauthority:/root/.Xauthority:rw" --entrypoint /bin/bash opencv32:0.1.1
-- Start Container
docker start <container name>
-- Execute container
docker exec -it <container name> bash
-- commit docker (if u install certain package, you should commit the docker in a new version)
docker commit <container name> <image name>:<update version>
-- save docker image
docker save -o <output file name>.tar <docker image>
-- jika setting gui seperti pada build container di atas tak jalan
--------
# Expose your xhost
xhost +local:docker
# When you finish, you can return the access control by using the following
#xhost -local:docker
# Add environment variables
XSOCK=/tmp/.X11-unix
XAUTH=/tmp/.docker.xauth
# Create the authentication files
touch /tmp/.docker.xauth
# Create permission
xauth nlist $DISPLAY | sed -e 's/^..../ffff/' | xauth -f $XAUTH nmerge -
--------
-- Download repo dengan password
RUN git clone https://username:[email protected]/username/repository.git
-- Copy file from host to docker
COPY <local file> <destination>
COPY <local folder + /> destination
----- NOTE: the files or folder is in same directory with dockerfile