This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| virtualization:docker [2022/02/06 13:39] – jotasandoku | virtualization:docker [2023/11/02 14:38] (current) – external edit 127.0.0.1 | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| **__DOCKER__**\\ | **__DOCKER__**\\ | ||
| Emulate only the user space. Container engine isolates user spaces. | Emulate only the user space. Container engine isolates user spaces. | ||
| - | * cgroups: kernel mechanism for limiting and measuring the total resources used by a group of processes running on a system. For example, you can apply CPU, memory, network or IO quotas. cgroups | + | |
| - | * namespaces: Namespaces are a kernel mechanism for limiting the visibility that a group of processes has of the rest of a system. For example you can limit visibility to certain process trees, | + | |
| Tutorial, all [[https:// | Tutorial, all [[https:// | ||
| - | The principle of docker is we start a container to __Run a Task__. If there' | + | The principle of docker is we start a container to __Run a Task__. If there' |
| - | **TODO:** docker/ | + | |
| - | \\ | + | |
| - | Normally, docker files live in: | + | |
| - | usermod -aG docker jsantosa # so we can run it under non-root | + | |
| - | [jotasancent@localhost Desktop]$ sudo ls -l / | + | |
| - | total 56 | + | |
| - | drwx------. 20 root root 4096 Jul 10 12:50 containers | + | |
| - | drwx------. | + | |
| - | / | + | |
| - | Show running container: | + | |
| - | docker ps -a | + | |
| - | note: PORTS means the TCP ports exposed by the container. | + | |
| - | Manage Imaged and Containers: | ||
| - | docker ps -a # running containers | ||
| - | docker images | ||
| - | docker search < | ||
| - | docker rm -f [container name or ID] | ||
| - | docker rmi [image name or ID] | ||
| - | With cli access | + | ---- |
| - | docker run -it ubuntu # start and connect to shell | + | |
| - | docker inspect 25b4bff1417c | jq . # to check the instance params without having to connect to it | + | |
| - | docker exec -it "id of running container" | + | |
| RUN container: | RUN container: | ||
| - | docker run -it --rm {image-name} / | + | docker run -it --rm |
| docker run --rm -v /foo -v awesome:/ | docker run --rm -v /foo -v awesome:/ | ||
| cat / | cat / | ||
| Line 38: | Line 17: | ||
| Flags to be run with //docker run// (see //man docker-run// | Flags to be run with //docker run// (see //man docker-run// | ||
| - | d <-- to run container in the background | + | |
| - | i <-- interactive | + | |
| - | t <-- allocate a pseudo-tty and attach to the standard input of any container | + | |
| - | P <-- flag is new and tells Docker to map any required network ports inside our container to our host | + | |
| Stop a container: | Stop a container: | ||
| docker stop f51e9de57784 | docker stop f51e9de57784 | ||
| docker restart < | docker restart < | ||
| + | docker run -itd --name c3 busybox | ||
| + | docker run -it --name c2 busybox | ||
| docker exec -it "id of running container" | docker exec -it "id of running container" | ||
| | | ||
| + | Remove all running and exited container (USER WITH CARE!): | ||
| + | docker container kill $(docker ps -q) | ||
| + | docker rm $(docker ps -a -f status=exited -q) | ||
| + | |||
| To list containers, stop them , get logs etc, | To list containers, stop them , get logs etc, | ||
| | | ||
| Line 59: | Line 44: | ||
| To delete an image | To delete an image | ||
| docker rmi [OPTIONS] IMAGE [IMAGE...] | docker rmi [OPTIONS] IMAGE [IMAGE...] | ||
| + | |||
| + | |||
| + | ---- | ||
| + | |||
| + | \\ | ||
| + | Normally, docker files live in: | ||
| + | usermod -aG docker jsantosa # so we can run it under non-root | ||
| + | [jotasancent@localhost Desktop]$ sudo ls -l / | ||
| + | total 56 | ||
| + | drwx------. 20 root root 4096 Jul 10 12:50 containers | ||
| + | drwx------. | ||
| + | / | ||
| + | Show running container: | ||
| + | docker ps -a | ||
| + | note: PORTS means the TCP ports exposed by the container. | ||
| + | |||
| + | Manage Imaged and Containers: | ||
| + | docker ps -a # running containers | ||
| + | docker images | ||
| + | docker search < | ||
| + | docker rm -f [container name or ID] | ||
| + | docker rmi [image name or ID] | ||
| + | |||
| + | '' | ||
| + | docker run -it ubuntu # start and connect to shell | ||
| + | docker inspect 25b4bff1417c | jq . # to check the instance params without having to connect to it | ||
| + | docker exec -it "id of running container" | ||
| + | | ||
| + | | ||
| | | ||
| Creating images: | Creating images: | ||
| Line 72: | Line 86: | ||
| ---- | ---- | ||
| - | DOCKER | + | __**DOCKER |
| * driver: | * driver: | ||
| * host | * host | ||
| Line 80: | Line 94: | ||
| * veth0,1.. | * veth0,1.. | ||
| - | | + | |
| + | docker run -itd --rm --name C1 --network=br0 busybox | ||
| [[https:// | [[https:// | ||
| Line 88: | Line 103: | ||
| - | |||
| - | ---- | ||
| - | |||
| - | **__DOCKER NETWORKING__**: | ||
| __IPV6__\\ | __IPV6__\\ | ||