I have a weird problem: I have a Ubuntu host machine running Docker and docker-compose. On the host, I’ve spun up one Ubuntu docker container. Here’s the weirdness: From the host, I can do a “git clone” to pull down a code project. From the container, I issue the same “git clone” command; nothing happens. Could this be a host networking thing?
Details: My host machine is a Ubuntu 16.04 machine, with Docker and docker-compose installed:
root@myHost:~# root@myHost:~# lsb_release -a No LSB modules are available. Distributor ID: Ubuntu Description: Ubuntu 16.04.7 LTS Release: 16.04 Codename: xenial root@myHost:~# root@myHost:~# docker --version Docker version 20.10.7, build 20.10.7-0ubuntu1~18.04.1 root@myHost:~# docker-compose --version docker-compose version 1.17.1, build unknown root@myHost:~#
The container is the current “latest” image of Ubuntu:
root@host1:~$ root@host1:~$ sudo docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES f7586f98afcf 54c9d81cbb44 "bash" 22 hours ago Up 22 hours myContainer root@host1:~$ root@host1:~$ sudo docker image ls REPOSITORY TAG IMAGE ID CREATED SIZE ubuntu latest 54c9d81cbb44 6 days ago 72.8MB root@host1:~$
docker-compose.yml file that creates the container; note that I’m using “host” networking:
version: "3.0" services: autotest_svr: container_name: myContainer hostname: myCntr image: 54c9d81cbb44 stdin_open: true tty: true network_mode: "host"
Okay, now to the problem:
On the host, I can run a “git clone” command to pull a project off my company’s internal github repo, no problem:
me@host1:~/myCode$ sudo git clone https://companyrepo.company.com/project01/projectCode git --branch 1234 Cloning into 'git'... Username for 'https://companyrepo.company.com': me Password for 'https://email@example.com': ******** remote: Counting objects: 623, done. remote: Compressing objects: 100% (401/401), done. remote: Total 623 (delta 271), reused 212 (delta 123) Receiving objects: 100% (623/623), 6.96 MiB | 2.54 MiB/s, done. Resolving deltas: 100% (271/271), done. Checking connectivity... done. me@host1:~/myCode$ me@host1:~/myCode$ me@host1:~/myCode$ ls -l total 4 drwxr-xr-x 4 root root 4096 Feb 8 15:21 git me@host1:~/myCode$
But in the container, its a different story. I can ping the company’s git repo, but when I issue the exact same “git clone” command, this happens:
me@myCntr:~/myCode$ sudo git clone https://companyrepo.company.com/project01/projectCode/ git --branch 1234 Cloning into 'git'... ...pause... fatal: unable to access 'https://companyrepo.company.com/project01/projectCode/': Received HTTP code 503 from proxy after CONNECT me@myCntr:~/myCode$
That pause is a few minutes long. The HTTP error code 503 (“Service Unavailable”) is clearly not the case: I know the Git Repo is available. Instead, it seems that when my container sends the “git clone” request, it never gets a response.
So: I can ping the repo, but can’t pull code. I’m not sure what to make of this. Could this be a “host” networking issue? I thought that when you set “host” networking, you’re essentially allowing the container to NAT behind the host’s IP address. So from the Git Repo’s perspective, there should be no (networking) difference between the host and container. What might be the issue here? Any suggestions, advice, or criticism is welcome. Thank you!