Skip to content
Advertisement

How to test Docker container on another machine?

I wrote a simple script as follows:

#main.py

def test_function():
    val = input('please enter a number')
    for i in range(int(val)):
        print (i)

I dockerized it and put it in a container, and ran it from there. Everything is working fine.

I have another machine with Linux OS. How can I test this container there? Do I need to simply copy paste it or what?

Advertisement

Answer

You need to install Docker on the other machine, and then push the image to a docker registry (e.g dockerhub / AWS ECR).

I use ECR. You need to create a registry and then tag your docker image with the url of the registry by running docker tag <source image> <url of the registry>, then run docker push <image name>

and to pull it from the other machine, run docker pull <url of the rigistry>

Or, you could just simply install docker on the other machine, copy the dockerfile there, and run docker build -t <image name> /path/to/file

Advertisement