act/pkg/container
sillyguodong 9283cfc9b1 Fix container network issue (#56)
Follow: https://gitea.com/gitea/act_runner/pulls/184
Close https://gitea.com/gitea/act_runner/issues/177

#### changes:
- `act` create new networks only if the value of `NeedCreateNetwork` is true, and remove these networks at last. `NeedCreateNetwork` is passed by `act_runner`. 'NeedCreateNetwork' is true only if  `container.network` in the configuration file of the `act_runner` is empty.
- In the `docker create` phase, specify the network to which containers will connect. Because, if not specify , container will connect to `bridge` network which is created automatically by Docker.
  - If the network is user defined network ( the value of `container.network` is empty or `<custom-network>`.  Because, the network created by `act` is also user defined network.), will also specify alias by `--network-alias`. The alias of service is `<service-id>`. So we can be access service container by `<service-id>:<port>` in the steps of job.
- Won't try to `docker network connect ` network after `docker start` any more.
  - Because on the one hand,  `docker network connect` applies only to user defined networks, if try to `docker network connect host <container-name>` will return error.
  - On the other hand, we just specify network in the stage of `docker create`, the same effect can be achieved.
- Won't try to remove containers and networks berfore  the stage of `docker start`, because the name of these containers and netwoks won't be repeat.

Co-authored-by: Jason Song <i@wolfogre.com>
Reviewed-on: https://gitea.com/gitea/act/pulls/56
Reviewed-by: Jason Song <i@wolfogre.com>
Co-authored-by: sillyguodong <gedong_1994@163.com>
Co-committed-by: sillyguodong <gedong_1994@163.com>
2023-05-16 14:03:55 +08:00
..
testdata fix: support docker create arguments from container.options (#1022) (#1351) 2022-10-06 22:09:43 +00:00
container_types.go Support services (#42) 2023-04-19 11:23:28 +08:00
docker_auth.go feat: add support for building docker actions with private registries (#1557) 2023-01-12 21:29:30 +00:00
docker_build.go Pass dockerfile to build executor (#1606) 2023-02-08 17:14:43 +00:00
docker_cli.go feat: Allow building without docker support (#1507) 2023-01-10 22:08:57 +00:00
docker_cli_test.go build(deps): bump github.com/docker/cli from 23.0.0-rc.1+incompatible to 23.0.0+incompatible (#1611) 2023-02-06 12:33:42 +00:00
docker_images.go refactor: remove docker image list reference filter (#1501) 2023-01-13 17:52:54 +00:00
docker_images_test.go refactor: move from io/ioutil to io and os packages (#1417) 2022-10-29 17:15:38 +00:00
DOCKER_LICENSE fix: support docker create arguments from container.options (#1022) (#1351) 2022-10-06 22:09:43 +00:00
docker_logger.go feat: Allow building without docker support (#1507) 2023-01-10 22:08:57 +00:00
docker_network.go Add go build tag to docker_network.go (#44) 2023-04-19 16:19:38 +08:00
docker_pull.go feat: Allow building without docker support (#1507) 2023-01-10 22:08:57 +00:00
docker_pull_test.go Improve logging (#1171) 2022-06-17 15:55:21 +00:00
docker_run.go Fix container network issue (#56) 2023-05-16 14:03:55 +08:00
docker_run_test.go feat: Host environment (#1293) 2022-11-16 21:29:45 +00:00
docker_stub.go Add go build tag to docker_network.go (#44) 2023-04-19 16:19:38 +08:00
docker_volume.go feat: Allow building without docker support (#1507) 2023-01-10 22:08:57 +00:00
executions_environment.go fix: environment handling windows (host mode) (#1732) 2023-04-18 18:09:57 +00:00
file_collector.go chore: use new style octal (#1630) 2023-02-16 15:34:51 +00:00
file_collector_test.go chore: use new style octal (#1630) 2023-02-16 15:34:51 +00:00
host_environment.go Merge tag 'nektos/v0.2.45' 2023-05-04 17:45:53 +08:00
host_environment_test.go feat: Host environment (#1293) 2022-11-16 21:29:45 +00:00
linux_container_environment_extensions.go fix: environment handling windows (host mode) (#1732) 2023-04-18 18:09:57 +00:00
linux_container_environment_extensions_test.go feat: Host environment (#1293) 2022-11-16 21:29:45 +00:00
parse_env_file.go refactor: share UpdateFromEnv logic (#1457) 2022-12-06 16:19:27 +00:00
util.go feat: Host environment (#1293) 2022-11-16 21:29:45 +00:00
util_openbsd_mips64.go feat: Host environment (#1293) 2022-11-16 21:29:45 +00:00
util_plan9.go feat: Host environment (#1293) 2022-11-16 21:29:45 +00:00
util_windows.go feat: Host environment (#1293) 2022-11-16 21:29:45 +00:00