Add exec command flag of network #192

Merged
sillyguodong merged 3 commits from bugfix/fix_exec_network into main 2023-05-18 07:01:44 +00:00
sillyguodong commented 2023-05-17 07:55:46 +00:00 (Migrated from gitea.com)

Related to #184
Add command flag of network for exec, the default value of --network is empty string. Valid values are: host , bridge, <custom_network> and empty string.

Related to #184 Add command flag of `network` for `exec`, the default value of `--network` is empty string. Valid values are: `host `, `bridge`, `<custom_network>` and empty string.
a1012112796 commented 2023-05-17 10:29:23 +00:00 (Migrated from gitea.com)

sadly, still can't connect to services.

image

sadly, still can't connect to `services`. ![image](/attachments/c87f8b3a-fca0-4fd0-bd63-91f21b9d91f0)
sillyguodong commented 2023-05-17 10:39:32 +00:00 (Migrated from gitea.com)

@a1012112796 , What is your host when connect to pgsql? Host should be <service-id>
In my test, can be access to service container:
image

@a1012112796 , What is your host when connect to pgsql? Host should be `<service-id>` In my test, can be access to service container: ![image](/attachments/0ade7035-5742-4108-8ee6-a1d597a1c499)
a1012112796 commented 2023-05-17 11:41:17 +00:00 (Migrated from gitea.com)

@a1012112796 , What is your host when connect to pgsql? Host should be <service-id>
In my test, can be access to service container:
image

oh, I see, In actions defined in gitea repo, It has add a special config

image

after remove it, it works.

image

by the way, this change will hhave other error in github, I wondoer why the result is different...

image

/cc @techknowlogick

> @a1012112796 , What is your host when connect to pgsql? Host should be `<service-id>` > In my test, can be access to service container: > ![image](/attachments/0ade7035-5742-4108-8ee6-a1d597a1c499) oh, I see, In actions defined in gitea repo, It has add a special config ![image](/attachments/ba765a2b-fbd5-4db0-aec7-2f10695d6ac0) after remove it, it works. ![image](/attachments/9b9cb970-8c2c-4dff-b80e-5f26d8530737) by the way, this change will hhave other error in github, I wondoer why the result is different... ![image](/attachments/8e509ad6-5b8b-4d44-be75-ef94a329c8dd) /cc @techknowlogick
a1012112796 (Migrated from gitea.com) approved these changes 2023-05-17 11:47:46 +00:00
sillyguodong commented 2023-05-18 02:27:41 +00:00 (Migrated from gitea.com)

I wondoer why the result is different...

@a1012112796 Hi, The actions of Gitea on GH should run a job directly on the runner machine. So you need to append this record to the /etc/hosts. as you can see, we must map the ports on the service container to ports on the Docker host in this mode.
image
But for Gitea Actions, each job is executed inside docker container by default. And act_runner will created a new docker network for job container and its service containers. All these containers will connect to this network, and we use <service-id> as an alias when service container connect to the network. So we can be access to the service containers by <service-id>:<port> in the steps of job.

> I wondoer why the result is different... @a1012112796 Hi, The actions of Gitea on GH should run a job directly on the runner machine. So you need to append this record to the `/etc/hosts`. as you can see, we must map the ports on the service container to ports on the Docker host in this mode. ![image](/attachments/b21ff257-0b83-4405-8aa8-6e592b7c619f) But for `Gitea Actions`, each job is executed inside docker container by default. And `act_runner` will created a new docker network for job container and its service containers. All these containers will connect to this network, and we use `<service-id>` as an alias when service container connect to the network. So we can be access to the service containers by `<service-id>:<port>` in the steps of job.
wolfogre (Migrated from gitea.com) approved these changes 2023-05-18 03:56:46 +00:00
Sign in to join this conversation.