How do I connect two images in a network?

I have both images running but I dont know how to properly connect them.

I have a docker network all done, I have both images running. But I cant figure out what the right commands are to do it.

the code I’ve done:

docker run --heuristic_leakey --network network-deux -d digibib/koha
docker run --trusting_bouman --network network-deux -d mysql
unknown flag: --heuristic_leakey

Usage: docker run [OPTIONS] IMAGE [COMMAND] [ARG…]

Run ‘docker run --help’ for more information
unknown flag: --trusting_bouman

Usage: docker run [OPTIONS] IMAGE [COMMAND] [ARG…]

Run ‘docker run --help’ for more information
$ docker run – heuristic_leakey --network network-deux -d digibib/koha
docker run – trusting_bouman --network network-deux -d mysql
Unable to find image ‘heuristic_leakey:latest’ locally
docker: Error response from daemon: pull access denied for heuristic_leakey, repository does not exist or may require ‘docker login’

Run ‘docker run --help’ for more information
Unable to find image ‘trusting_bouman:latest’ locally
docker: Error response from daemon: pull access denied for trusting_bouman, repository does not exist or may require ‘docker login’

code i loooked up as a try:
docker network create my-network

docker run -d --name container1 --network my-network <image_name_1>
docker run -d --name container2 --network my-network <image_name_2>

what am I doing wrong and what should I be doing right??

docker run --heuristic_leakey --network network-deux -d digibib/koha
           ^

What kind of Docker option is that supposed to be? Did you want to use --name something?

But why would you set a random name, which is usually created by Docker if no name is given?

I used a random name cause I wanted to test out what I wanted to Do.

It’s supposed to be names of containers then images that are trying to connect via docker bridge option.

Like connect two different containers/images in one network.

Check the syntax again.

Not

docker run --heuristic_leakey

but

docker run --name heuristic_leakey

when I try that, I get this error, even when I delete the containers.

the code I entered:
docker run --name heuristic_leakey --network network-deux -d digibib/koha
docker run --name trusting_bouman --network network-deux -d mysql

what I got in return
84a268d996943cc659f1e7f0cb1da1fe4e5918b04f53e2ca57be8849509e56db

and:

docker: Error response from daemon: Conflict. The container name “/trusting_bouman” is already in use by container “ad1137a4f047c9f0f95540618a6c7d8f96f59c67ab55889f2ff2246604749bd0”. You have to remove (or rename) that container to be able to reuse that name.

and the containers reshow up, but they don’t run at all.

Run docker ps -a to see all containers, even stopped ones. You need to remove an old container before you can run a new one with the same name. I think the error message is pretty clear.

That’s why docker run without --name attribute will assign random names when starting a new container, so no conflict with the name.

is it reccomended to use my own file names or use randomly assigned names?

If you want to connect from one container to another, you should use fixed names.

I’m general I would suggest to check docker compose and use compose files. At first it’s different from using plain docker run on CLI, but has a lot of advantages when using multiple services.

Could you give examples so I have an idea?

Have you checked the doc?

Did you check the Docker “Getting started” or any other tutorial?

This website can help you to transform docker run commands to docker compose files: