This post is written for OpenShift - OCP & Docker to demonstrate the idea
Why? Or use cases
-
The Docker image somehow is not cached, you need to keep as much as possible from the last image, and you need to see the result quickly in the server environment
-
Or you just need to test something immediately on the server (for instance, when your script can only be tested in the server environment)
How?
If you have 1 pod only:
oc rsh <pod-name>
- Step 1:
cat > <file-you-want-to-modify>
- Step 2: Paste the new content
- Step 3:
control + D
(or if you control + C then remember to Enter first)
If you have multiple pods:
- Step 1:
docker ps
- Step 2:
docker exec -it <container-ID> bash
- Step 3: Make the changes
- Step 4:
docker commit <container-ID> <image-name:version>
# The 4 steps above are enough to update the code quickly
# Below are only the following steps to apply it
docker tag <image-name:version> <link:version>
docker push <link:version>
# Update the image field in your deployment YAML file,
# then apply the changes:
oc apply -f <yaml-file>