Skip to main content

Kubernetes alternatives to docker commands


Nowadays, Docker environment is very common in the software engineering:

  • most of the getting started explain how to start the official image of the software in your local docker engine
  • most of the engineering environments, especially on the software developer laptops, includes docker engine
  • Docker has been launch a long time before kubernetes

However, Docker suffers from several limitations:

  • the docker licensing model has changed, forcing some enterprise to subscribe to expensive licenses
  • kubernetes brings additional concepts that are not include with docker, such as ingresses or storage classes
  • limited high availability

That's why in some cases, it could be interesting to adapt some very common docker commands to kubernetes; and then benefits from k8saas.

Docker pull

Docker pull downloads a docker image from a remote artefact repository to your internal docker artefact repository:

docker pull repository name/docker image name


docker pull wallarm/gotestwaf

The kubernetes alternative consists of downloading the docker image and starting the image on your remote kubernetes cluster using an infinite loop:

kubectl create deployment --image=repository name/docker image name kubernetes deployment name -- /bin/sh -ec "while :; do echo '.'; sleep 5 ; done"


# in default namespace
kubectl create deployment --image=wallarm/gotestwaf gotestwaf -- /bin/sh -ec "while :; do echo '.'; sleep 5 ; done"

# in dev namespace
kubectl create deployment --image=wallarm/gotestwaf gotestwaf -n dev -- /bin/sh -ec "while :; do echo '.'; sleep 5 ; done"

this method works only if your docker image contains /bin/sh

Docker run

Docker run command starts the image and execute the command you requests.

docker run repository name/docker image name command args


docker run wallarm/gotestwaf /app/gotestwaf --url=

The kubernetes alternatives just executes the command you request directly on the running container.

kubectl exec -it docker pod name -- command args


kubectl -n dev -c gotestwaf exec -it gotestwaf-757955bdcf-bkkr7 -- /app/gotestwaf --url=

in the previous example:

  • the namespace is dev
  • the pod contains multiple containers, so the container must be specified with -c
  • pod name is different from deployment name. Check the correct name using kubectl get pods


Copy remote files to local

If you use the previous commands, you may need to get access to generated files on the container. To do so:

kubectl cp namespace/docker pod name:/YOUR_ABSOLUTE_PATH LOCAL_PATH


kubectl cp dev/gotestwaf-757955bdcf-bkkr7:/app/reports/waf-evaluation-report-2022-May-03-09-25-35.pdf /tmp/waf-evaluation-report-2022-May-03-09-25-35.pdf -c gotestwaf

kubectl cp should be used only to get only small files (few MBs)