Your requirements show that you are using Hadoop in fully distributed mode. I'll redirect you to a site which must help you with the image you need.
Here containers can be run as both master and worker.
#docker network create hadoop
#docker run -d -p 50070:50070 -p 8088:8088 \
# --network hadoop --name hadoop-dotnet-master \
# sixeyed/hadoop-dotnet master
#docker run -d -p 50075:50075 -p 8142:8042 -p 19888:19888 \
# --network hadoop
# sixeyed/hadoop-dotnet worker
Or if you wish to run a fully distributed cluster with a docker composer file, then I this must be the solution