fail connection udp server in docker

I quite new in docker and network and I have a udp servet with two ports for listen and send message and the same in the client side. The goal of this connection is they are synchronising the flags which the server is on a docker container and the client is on local host.
Here is the server code:

import socket
import time
import random


class Physical:

    def __init__(self, remote_ip, remote_port, port, t):
        self.remote_ip = remote_ip
        self.remote_port = remote_port
        self.port = port
        self.t = t
        self.tick = 0
        self.ctrl_flag = 0
        self.ctrl_url = None
        self.sw_state = 0
        self.sw_package = None
        self.receive_socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
        self.send_socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
        self.receive_socket.bind(("0.0.0.0", self.port))

    def run(self):
        while True:
            # input here
            if random.randint(0, 20) <= 3:
                self.ctrl_flag = random.randint(0, 10)
                print("in ctrl_flag {} {}".format(self.ctrl_flag, self.tick))
            else:
                print("same ctrl_flag {} {}".format(self.ctrl_flag, self.tick))

            self.receive_sync()
            # intermediary states
            self.tick += 1
            self.send_sync()
            print("new ctrl_flag {}, {}n".format(self.ctrl_flag, self.tick))

    def send_sync(self):
        self.send_socket.sendto("{}".format(self.ctrl_flag).encode(), (self.remote_ip, self.remote_port))

    def receive_sync(self):
        data, addr = self.receive_socket.recvfrom(256)
        self.ctrl_flag = int(data)


def main():
    phy = Physical("0.0.0.0", 5555, 5556, 0)
    phy.run()


if __name__ == "__main__":
    main()

The client code is:

import socket
import random
import asyncio
#SERVER = socket.gethostbyname(socket.gethostname())

class Twin:

    def __init__(self, remote_ip, remote_port, port, t):
        self.remote_ip = remote_ip
        self.remote_port = remote_port
        self.port = port
        self.t = t
        self.tick = 0
        self.ctrl_flag = 0
        self.ctrl_url = None
        self.sw_state = 0
        self.sw_package = None
        self.receive_socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
        self.send_socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
        self.receive_socket.bind(("127.0.0.1", self.port))

    async def run(self):
        while True:
            # time.sleep(self.t)
            await asyncio.sleep(self.t)
            # input here
            if random.randint(0, 20) <= 3:
                self.ctrl_flag = random.randint(0, 10)
                print("in ctrl_flag {}, ticket {}".format(self.ctrl_flag, self.tick))
            else:
                print("same ctrl_flag {}, ticket {}".format(self.ctrl_flag, self.tick))

            self.send_sync()
            # intermediary state
            self.tick += 1
            self.receive_sync()
            print("new ctrl_flag {}, ticket {}n".format(self.ctrl_flag, self.tick))

    def send_sync(self):
        self.send_socket.sendto("{}".format(self.ctrl_flag).encode(), (self.remote_ip, self.remote_port))

    def receive_sync(self):
        data, addr = self.receive_socket.recvfrom(256)
        self.ctrl_flag = int(data)


def main():
    twin = Twin("127.0.0.1", 5556, 5555, 2)
    loop = asyncio.get_event_loop()
    # loop.call_later(time, twin.stop())
    task = loop.create_task(twin.run())
    try:
        loop.run_until_complete(task)
    except asyncio.CancelledError:
        pass


if __name__ == "__main__":
    main()

The dockerfile to build the image is:

FROM python:3.9

WORKDIR /Physical

COPY . /Physical

EXPOSE 5555/udp

EXPOSE 5556/udp

ENV NAME digitaltwin

CMD ["python3", "-u", "Physical.py"]

For running the image once I used this command docker run -p 5555:5550/udp -p 5556:5559/udp digitaltwin:latest the server and the client couldn’t connect without any specific error but it was like they were running separatly and couldn’t go forward to sync the flags.
The other command I used was forwarding the same port to the docker container docker run -p 5555:5555/udp -p 5556:5556/udp digitaltwin:latest when I tried to run the client the error was the address is allocated already.

Does anyone know how I can fix it?

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật