How to
Install Docker Community Edition ( DockerCE )
Uninstall Docker
Remove all non-used docker containers
Removing "<none>" images
Show real-time logs from the initialized container
Size of container
Get running containers
Name
JSON
Show online/offline containers
Create temporary containers
Docker Service Providers DNS
Specify DNS servers for Docker
Memory
For instance, let's limit the memory that the container can use to 512 megabytes. To constrain memory, we need to use the m parameter:
We can also set a soft limit called a reservation. It's activated when docker detects low memory on the host machine:
CPU
By default, access to the computing power of the host machine is unlimited. We can set the CPUs limit using the cpus parameter. For example, let's constrain our container to use at most two CPUs:
We can also specify the priority of CPU allocation. The default is 1024, higher numbers are higher priority:
Similar to the memory reservation, CPU shares play the main role when computing power is scarce and needs to be divided between competing processes.
Setting Memory Limit With the docker-compose File
We can achieve similar results using docker-compose files. Mind that the format and possibilities will vary between versions of docker-compose.
Versions 3 and Newer With docker swarm
Let's give the Nginx service limit of half of CPU and 512 megabytes of memory, and reservation of a quarter of CPU and 128 megabytes of memory. We need to create “deploy” and then “resources” segments in our service configuration:
To take advantage of the deploy segment in a docker-compose file, we need to use the docker stack command. To deploy a stack to the swarm, we run the deploy command:
Version 2 With docker-compose
In older versions of docker-compose, we can put resource limits on the same level as the service's main properties. They also have slightly different naming:
To create configured containers, we need to run the docker-compose command:
Verifying Resources Usage
After we set the limits, we can verify them using the docker stats command:
MACOS
Set Bridge IP (docker bip)
If the Docker Engine default bridge network is conflicting with your internal network hosts access, you can change the default Docker subnet by following these steps:
First, you need to delete your old containers
Next, change the subnet IP inside "/etc/docker/daemon.json", by using this command:
Type in the Netmask IP. With the following structure. Please keep in mind that the IP used here is an example:
Restart the Docker Daemon by using this command:
Create a new VSS container and postgres with the following command:
And that’s it!
Docker unable to access from VPN
Linux
Check your subnet IP here
Reset your networks to set correct subnet ip
Using Docker Compose + OpenVPN
Set the content below inside your docker-compose file:
Windows
Set a "default-address-pool"
Set a subnet network inside the
docker-compose
file
Last updated