Docker operation memo

usage environment

VirtulBox : 6.1 Host OS: Ubuntu 18.04 Docer : docker-ce 19.03.13

Image execution

When booting CentOS with privileges.

$ sudo docker run -itd --privileged --name PROCESS_NAME IMAGE_NAME /sbin/init
$ sudo docker run -itd --privileged -p 8080:80 --name PROCESS_NAME IMAGE_NAME /sbin/init
↑ When specifying the port, it looks like this

Checking the status of the container

Stream

$ sudo docker stats centos8

Do not stream

$ sudo docker stats centos8 --no-stream

Set memory limit after booting

I stumbled in various ways, but succeeded by doing the following.

$ sudo docker update -m 1G --memory-swap -1 CONTAINER_ID

The following things such as stumbling

At first, I executed the following command, but an error occurred.

$ sudo docker update -m 1G CONTAINER_ID
Your kernel does not support swap limit capabilities or the cgroup is not mounted. Memory limited without swap.

Solved by changing the swap setting of grub.

$ sudo vi /etc/default/grub
$ sudo update-grub
grub.Update cfg and restart the host OS.

When I re-executed it after restarting, the following error occurred.

$ docker update -m 1G 917f3986a06b
Error response from daemon: Cannot update container 917f3986a06bb9f99b095af4f3e5334ce125f596f9926db2733bdb4d20868b47: Memory limit should be smaller than already set memoryswap limit, update the memoryswap at the same time

So, I set the "--memory-swap -1" option and executed it, and it succeeded.

When the memory is loaded as shown below, it can be confirmed that the 1G limit is applied.

$ docker exec -it centos8 /bin/bash
# /dev/null < `yes`
$ docker stats centos8 --no-stream
CONTAINER ID        NAME                CPU %               MEM USAGE / LIMIT   MEM %               NET I/O             BLOCK I/O           PIDS
917f3986a06b        centos8             106.50%             1GiB / 1GiB         100.00%             15.4kB / 10.4kB     52.3MB / 4.1kB      229

Recommended Posts

Docker operation memo
docker memo
docker tutorial (memo)
Docker command memo
[Memo] docker summary
Bit operation speedup memo
Docker x Rails 6 (memo)
docker inspect --format memo
Docker Machine command memo
About simple operation of Docker
MySQL 5.7 (Docker) environment construction memo
Redmine (Docker) environment construction memo
Lombok's @Getter @Setter operation memo
docker
Installing and building Docker (memo)
Docker execution memo summarized for myself
[Docker] Operation up to container creation # 2
[Personal memo] About button (GUI) operation of Docker Desktop for Windows
kubernetes + docker
spring × docker
About Docker
Re-study Docker from a system operation perspective
Lombok memo
Docker Intellij
Dockerfile memo
Iterator memo
Docker basics
corretto memo
Java memo
AWS memo
Docker installation
About Docker
Docker command
Docker memorandum
Understand Docker
Docker memorandum
Dcokerfile memo
Install Docker with WSL2 Memo ([Part 2] Docker introduction)
Ruby memo
Build TensorFlow operation check environment with Docker
Memo Stream
[Memo] Create a CentOS 8 environment easily with Docker
Environment construction command memo with Docker on AWS
Docker + Java + SpringBoot WEB development hands-on attendance memo (2019/08/19)