-
Notifications
You must be signed in to change notification settings - Fork 1
/
docker
54 lines (36 loc) · 1.32 KB
/
docker
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
# Fix permission error to connect to docker daemon
# issue this command and reboot the machine
sudo usermod -a -G docker $USER
# Example of a DockerFile
from ubuntu:latest
copy example_1_nonet.bin /
copy libc.so.6 /
copy ld-linux-x86-64.so.2 /
entrypoint [ "/ld-linux-x86-64.so.2", "--library-path", "/", "/example_1_nonet.bin", "secret_of_life", "supersecretpassword" ]
# Build a docker container given a DockerFile
# give the folder that contains the DockerFile and all the binaries
# you need.
# This will give you a docker container id -> f.i. be3ced322578
docker build example_1_nonet/
# List all images
docker image ls
# List all running containers
docker container ls
# Run a container
docker run c185416be9f3
# Run a container interactively
docker run -it c185416be9f3
# Run a container and spawn a shell inside it
# Remember to remove any entry_point in the DockerFile
docker run -it c185416be9f3 bash
# Execute a command in a running container
docker exec -it "id of running container" bash
# Remove a specific image
docker rmi "id of image"
# Remove all images
docker system prune
# Commit the work in a container
# the commit will create a new image that you can see thourgh the `docker image ls` command
docker commit <commit_id>
# Spawn a new docker with ubuntu:16.04
docker run --rm -it ubuntu:16.04