Let docker containers work with each other
What would be the best way to share ports among the containers? 


You don't really "share" ports between containers. Instead, you want to create network and attach each container to that network.  Each container gets a network alias (essentially a hostname) that you can use to hit the service. 

$ docker network create foo
$ docker run --network=foo --network-alias=mysql -p 3306:3306 my-mysql:latest
$ docker run --network=foo --network-alias=restapi -p 5000:5000 --link mysql my-restapi:latest
$ docker run --network=foo --network-alias=react -p 3000:3000 --link restapi my-reactapp:latest


So the myrestapi container can access the mysql container using the hostname mysql and port 3306 and your react app can hit the myrestapi container using the hostname restapi.  The containers will also be accessible from your localhost so you can hit your react app with a browser without additional setup

In docker-compose.yml (which I don't use a ton so someone may have a better solution), it would look something like this:

networks: 
  foo:
services:
  mariadb:
    container_name: mysql # this works for your alias so long as you don't have another container called mysql
    image: mariadb:latest
    networks: ["foo"]
    ports:
    - 3306:3306


The other services would follow suit.

As for "priming" the database, that's a little trickier. If the DB has to be running, you would need to replace the docker container's entrypoint to start the server, run the mysql command to import the data, then your script would just spin forever.

Alternately, you could script your container start-up and after it starts, import the data that way.