add hosts redirection in docker

后端 未结 2 769
粉色の甜心
粉色の甜心 2021-02-08 21:38

I use gitlab in a Virtual machine . And I will use gitlab-ci (in the same VM), with docker .

For access to my gitlab, I use the domain git.local ( redirect to my VM on m

2条回答
  •  野的像风
    2021-02-08 21:58

    if you want to use dns in docker use dns-gen follow these simple steps by this step you can assign host name to multi docker containers. 1. First know your docker IP by Publishing this command

    /sbin/ifconfig docker0 | grep "inet" | head -n1 | awk '{ print $2}' | cut -d: -f2

    1. now note the output ip and time to start dns-gen container(ps: don't forget to add docker ip you get by issuing above command before :53:53)

    docker run --detach \ --name dns-gen \ --publish dockerip:53:53/udp \ --volume /var/run/docker.sock:/var/run/docker.sock \ jderusse/dns-gen

    1. Last thing: Register you new DnsServer in you resolv.conf

    echo "nameserver dockerip" | sudo tee --append /etc/resolvconf/resolv.conf.d/head sudo resolvconf -u

    Now you should be able to access your docker container in browser :- http://containername.docker

    Hope it works.. Thanks..

    Shubhankit

提交回复
热议问题