I am trying to deploy different versions of apps to docker so that users can pickup the version they want to use. For example, I have two apps (programs-v1.0.0 and programs-v1.2.0) docker containers running on localhost, the one with port 8000 call be called without problem while the one with port 8080 cannot be called through the python script. There is no problem running both versions in interactive mode so I assume there is nothing wrong with the docker containers. I already changed the IP and port in python script for this service but don’t know why programs-v1.2.0 cannot be called while program-v1.0.0 works fine. Any suggestions? Thanks.
(base) ➜ apps-dsu git:(main) ✗ docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
8bb4b104a541 programs-v1.2.0 "python3 server/main…" 35 minutes ago Up 35 minutes 0.0.0.0:8080->8080/tcp determined_kirch
df184b8387dd programs-v1.0.0 "python3 server/main…" 41 minutes ago Up 41 minutes 0.0.0.0:8000->8000/tcp focused_diffie
6723d92116b2 b2eac8b8ed49 "/bin/sh" 2 months ago Exited (130) 2 months ago focused_galileo
278be857e7bb b9810ceb74d9 "/bin/bash" 2 months ago Exited (0) 2 months ago lucid_carver
9a300254de3c b9810ceb74d9 "/bin/bash" 2 months ago Exited (129) 2 months ago exciting_nightingale
27cf6d59ddc3 fb590c4e0825 "/bin/bash" 2 months ago Exited (0) 2 months ago busy_rubin
6a00ab114365 c2f43dad5e50 "/bin/bash" 2 months ago Exited (0) 2 months ago strange_mclaren
789eef79d1df 4eea455efdac "/bin/bash" 2 months ago Exited (127) 2 months ago fervent_raman
(base) ➜ al-ex-gaines-thomas-programs-default python ../../../server/script-programs-v2-local-port-8080.py ex11-al -local_storage ./result-v1.2.0.zip
Traceback (most recent call last):
File "/Users/danielsue/Soft/Anaconda3/lib/python3.8/site-packages/websockets/legacy/client.py", line 139, in read_http_response
status_code, reason, headers = await read_response(self.reader)
File "/Users/danielsue/Soft/Anaconda3/lib/python3.8/site-packages/websockets/legacy/http.py", line 120, in read_response
status_line = await read_line(stream)
File "/Users/danielsue/Soft/Anaconda3/lib/python3.8/site-packages/websockets/legacy/http.py", line 194, in read_line
line = await stream.readline()
File "/Users/danielsue/Soft/Anaconda3/lib/python3.8/asyncio/streams.py", line 540, in readline
line = await self.readuntil(sep)
File "/Users/danielsue/Soft/Anaconda3/lib/python3.8/asyncio/streams.py", line 632, in readuntil
await self._wait_for_data('readuntil')
File "/Users/danielsue/Soft/Anaconda3/lib/python3.8/asyncio/streams.py", line 517, in _wait_for_data
await self._waiter
File "/Users/danielsue/Soft/Anaconda3/lib/python3.8/asyncio/selector_events.py", line 848, in _read_ready__data_received
data = self._sock.recv(self.max_size)
ConnectionResetError: [Errno 54] Connection reset by peer
Thanks,
Daniel
Service of both programs-v1.2.0 and programs-v1.0.0 can be called.
Command I have used to build different versions of programs and run the container.
docker build -t programs --build-arg="v1.0.0" --tag=programs-v1.0.0 . -f docker/Dockerfile
docker run -d -p 8000:8000 programs-v1.0.0
docker build -t programs --build-arg="v1.2.0" --tag=programs-v1.2.0 . -f docker/Dockerfile
docker run -d -p 8080:8080 programs-v1.2.0
Command I have used to call the service
python ../../../server/script-porgrams-v1.0.0-local-port-8000.py ex11-al #(works fine)
python ../../../server/script-porgrams-v1.0.0-local-port-8080.py ex11-al #(error)
Below is part of the script I have used
# Example of script-porgrams-v1.0.0-local-port-8000.py
...
if __name__ == "__main__":
#Change the port accordingly when different versions are running, e.g., from 8000 to 8001.
#BASE_URL = "34.132.141.185:8000/"
BASE_URL = "127.0.0.1:8000/"
RUN_URL = f"http://{BASE_URL}run/"
# print('argument list', sys.argv)
PREFIX = sys.argv[1]
STORAGE_TYPE = sys.argv[2]
OUTPUT_FILE_PATH = sys.argv[3]
ARGS = sys.argv[4:]
# Directory path can also be part of the argument, if local path is provided.
DIRECTORY_PATH = "./"
# Generate a random client_id
client_id = str(uuid.uuid4())
WS_URL = f"ws://{BASE_URL}ws/{client_id}"
async def main():
start_time = time.time() # Start timing the process
async with websockets.connect(WS_URL, ping_timeout=60) as websocket:
print("WebSocket connection established.")
# Create a task for receiving WebSocket messages
ws_task = asyncio.create_task(receive_app_output(websocket))
# Run the app process
await run_app(
RUN_URL,
PREFIX,
ARGS,
DIRECTORY_PATH,
OUTPUT_FILE_PATH,
STORAGE_TYPE,
client_id,
)
# Wait for the WebSocket task to complete
await ws_task
end_time = time.time() # End timing the process
print(f"Total process time: {end_time - start_time} seconds")
asyncio.run(main())
# and example of main.py
...
if __name__ == "__main__":
uvicorn.run(app, host="0.0.0.0", port=8000)
# Example of script-porgrams-v1.0.0-local-port-8080.py
...
if __name__ == "__main__":
#Change the port accordingly when different versions are running, e.g., from 8000 to 8001.
#BASE_URL = "34.132.141.185:8000/"
BASE_URL = "127.0.0.1:8080/"
RUN_URL = f"http://{BASE_URL}run/"
# print('argument list', sys.argv)
PREFIX = sys.argv[1]
STORAGE_TYPE = sys.argv[2]
OUTPUT_FILE_PATH = sys.argv[3]
ARGS = sys.argv[4:]
# Directory path can also be part of the argument, if local path is provided.
DIRECTORY_PATH = "./"
# Generate a random client_id
client_id = str(uuid.uuid4())
WS_URL = f"ws://{BASE_URL}ws/{client_id}"
async def main():
start_time = time.time() # Start timing the process
async with websockets.connect(WS_URL, ping_timeout=60) as websocket:
print("WebSocket connection established.")
# Create a task for receiving WebSocket messages
ws_task = asyncio.create_task(receive_app_output(websocket))
# Run the app process
await run_app(
RUN_URL,
PREFIX,
ARGS,
DIRECTORY_PATH,
OUTPUT_FILE_PATH,
STORAGE_TYPE,
client_id,
)
# Wait for the WebSocket task to complete
await ws_task
end_time = time.time() # End timing the process
print(f"Total process time: {end_time - start_time} seconds")
asyncio.run(main())
# and example of main.py
...
if __name__ == "__main__":
uvicorn.run(app, host="0.0.0.0", port=8080)