Kubernetes 101 : Random useful Docker and Kubernetes commands



To limit the use of CPU -150m- and memory -1024- resources of an "nginx" container, we could use the below command for example:


"8080" : port on the host.
"80" : port on the container.

Remark:

"--cpu-shares" is a soft limit, the container uses more CPU is available.

To delete a docker image, we could use the below command:


To label a pod we could run the below command:


To execute a command inside a running container, we could use:


If the "bash" program is not available in our container, we could "attach" to the running pod and run our commands:


To copy files from a container to our host, we could use the below command:


To open a connection that forwards requests from the local host on port 8080 to the container on port 80 for example, we use the below command:


We could also use the command line to run an "nginx" container and expose its port using the below commands:


The above command creates a deployment of an "nginx" image with one replica.


The above command exposes the pod on port 80.
"--name" is the name of the new service through which client applications will access the pod.

Comments

Leave as a comment:

Archive