|
| 1 | +:_content-type: PROCEDURE |
| 2 | +:description: Running containers with kubedock |
| 3 | +:keywords: kubedock, container |
| 4 | +:navtitle: Running containers with kubedock |
| 5 | +:page-aliases: |
| 6 | + |
| 7 | +[id="running-containers-with-kubedock"] |
| 8 | += Running containers with kubedock |
| 9 | + |
| 10 | +link:https://github.com/joyrex2001/kubedock[Kubedock] is a minimal container engine implementation that gives you a Podman-/docker-like experience inside a {prod-short} workspace. Kubedock is especially useful when dealing with ad-hoc, ephemeral, and testing containers, such as in the use cases listed below: |
| 11 | + |
| 12 | +* Executing application tests which rely on link:https://testcontainers.com/[Testcontainers] framework. |
| 13 | + |
| 14 | +* Using link:https://quarkus.io/guides/dev-services[Quarkus Dev Services]. |
| 15 | + |
| 16 | +* Running a container stored in remote container registry, for local development purposes |
| 17 | + |
| 18 | +[IMPORTANT] |
| 19 | +==== |
| 20 | +The image you want to use with kubedock must be compliant with link:https://docs.openshift.com/container-platform/{ocp4-ver}/openshift_images/create-images.html#images-create-guide-openshift_create-images[Openshift Container Platform guidelines]. |
| 21 | +Otherwise, running the image with kubedock will result in a failure even if the same image runs locally without issues. |
| 22 | +==== |
| 23 | + |
| 24 | +.Enabling kubedock |
| 25 | + |
| 26 | +After enabling the kubedock environment variable, kubedock will run the following `podman` commands: |
| 27 | + |
| 28 | +* `podman run` |
| 29 | +* `podman ps` |
| 30 | +* `podman exec` |
| 31 | +* `podman cp` |
| 32 | +* `podman logs` |
| 33 | +* `podman inspect` |
| 34 | +* `podman kill` |
| 35 | +* `podman rm` |
| 36 | +* `podman wait` |
| 37 | +* `podman stop` |
| 38 | +* `podman start` |
| 39 | + |
| 40 | +Other commands such as `podman build` are started by the local Podman. |
| 41 | + |
| 42 | +[IMPORTANT] |
| 43 | +==== |
| 44 | +Using `podman` commands with kubedock has following limitations |
| 45 | +
|
| 46 | +* The `podman build -t <image> . && podman run <image>` command will fail. Use `podman build -t <image> . && podman push <image> && podman run <image>` instead. |
| 47 | +* The `podman generate kube` command is not supported. |
| 48 | +* `--env` option causes the `podman run` command to fail. |
| 49 | +==== |
| 50 | + |
| 51 | +.Prerequisites |
| 52 | +* An image compliant with link:https://docs.openshift.com/container-platform/{ocp4-ver}/openshift_images/create-images.html#images-create-guide-openshift_create-images[Openshift Container Platform guidelines]. |
| 53 | + |
| 54 | +.Process |
| 55 | +* Add `KUBEDOCK_ENABLED=true` environment variable to the devfile. |
| 56 | +** (OPTIONAL) Use the `KUBEDOCK_PARAM` variable to specify additional kubedock parameters. The list of variables is available link:https://github.com/joyrex2001/kubedock/blob/master/cmd/server.go[here]. Alternatively, you can use the following command to view the available options: |
| 57 | ++ |
| 58 | +[subs="+attributes,+quotes"] |
| 59 | +---- |
| 60 | +# kubedock server --help |
| 61 | +---- |
| 62 | + |
| 63 | +.Example |
| 64 | +[source,yaml,subs="+quotes,attributes"] |
| 65 | +---- |
| 66 | +schemaVersion: 2.2.0 |
| 67 | +metadata: |
| 68 | + name: kubedock-sample-devfile |
| 69 | +components: |
| 70 | + - name: tools |
| 71 | + container: |
| 72 | + image: quay.io/devfile/universal-developer-image:latest |
| 73 | + memoryLimit: 8Gi |
| 74 | + memoryRequest: 1Gi |
| 75 | + cpuLimit: "2" |
| 76 | + cpuRequest: 200m |
| 77 | + env: |
| 78 | + - name: KUBEDOCK_PARAMS |
| 79 | + value: "--reverse-proxy --kubeconfig /home/user/.kube/config --initimage quay.io/agiertli/kubedock:0.13.0" |
| 80 | + - name: USE_JAVA17 |
| 81 | + value: "true" |
| 82 | + - value: /home/jboss/.m2 |
| 83 | + name: MAVEN_CONFIG |
| 84 | + - value: -Xmx4G -Xss128M -XX:MetaspaceSize=1G -XX:MaxMetaspaceSize=2G |
| 85 | + name: MAVEN_OPTS |
| 86 | + - name: KUBEDOCK_ENABLED |
| 87 | + value: 'true' |
| 88 | + - name: DOCKER_HOST |
| 89 | + value: 'tcp://127.0.0.1:2475' |
| 90 | + - name: TESTCONTAINERS_RYUK_DISABLED |
| 91 | + value: 'true' |
| 92 | + - name: TESTCONTAINERS_CHECKS_DISABLE |
| 93 | + value: 'true' |
| 94 | + endpoints: |
| 95 | + - exposure: none |
| 96 | + name: kubedock |
| 97 | + protocol: tcp |
| 98 | + targetPort: 2475 |
| 99 | + - exposure: public |
| 100 | + name: http-booster |
| 101 | + protocol: http |
| 102 | + targetPort: 8080 |
| 103 | + attributes: |
| 104 | + discoverable: true |
| 105 | + urlRewriteSupported: true |
| 106 | + - exposure: internal |
| 107 | + name: debug |
| 108 | + protocol: http |
| 109 | + targetPort: 5005 |
| 110 | + volumeMounts: |
| 111 | + - name: m2 |
| 112 | + path: /home/user/.m2 |
| 113 | + - name: m2 |
| 114 | + volume: |
| 115 | + size: 10G |
| 116 | +---- |
| 117 | + |
| 118 | +[IMPORTANT] |
| 119 | +==== |
| 120 | +You must configure the Podman or docker API to point to kubedock setting |
| 121 | +`CONTAINER_HOST=tcp://127.0.0.1:2475` or `DOCKER_HOST=tcp://127.0.0.1:2475` when running containers. |
| 122 | +
|
| 123 | +At the same time, you must configure Podman to point to local Podman when building the container. |
| 124 | +==== |
| 125 | + |
0 commit comments