File tree 1 file changed +8
-3
lines changed
1 file changed +8
-3
lines changed Original file line number Diff line number Diff line change 3
3
# Get the IP address from the Docker container
4
4
docker_ip=$( docker run --rm alpine ip route | awk ' NR==1 {print $3}' )
5
5
6
- # Add a new entry to /etc/hosts
7
- echo " $docker_ip host.docker.internal" | sudo tee -a /etc/hosts
8
- echo " A new entry in the /etc/hosts file has been created"
6
+ # Check if the IP address already exists in /etc/hosts
7
+ if grep -q " $docker_ip host.docker.internal" /etc/hosts; then
8
+ echo " The entry already exists in /etc/hosts. No action needed."
9
+ else
10
+ # Add a new entry to /etc/hosts
11
+ echo " $docker_ip host.docker.internal" | sudo tee -a /etc/hosts
12
+ echo " A new entry in the /etc/hosts file has been created"
13
+ fi
9
14
10
15
# Ask the user whether to execute the iptables command
11
16
read -p " Do you want to open port 9003 for xdebug? (y/n): " choice
You can’t perform that action at this time.
0 commit comments