Connect to host application from a container at a specific port

I am running an application on host machine on port XYZ.

I was running a docker container and from the container, I need to connect to the application on the host machine on port XYZ

One way which I found out was to restart the container with the following flag

1
--add-host host.docker.internal:host-gateway

With this addition, you can refer to the application on the host machine from inside the container by going to host.docker.internal:XYZ

How to install Hexo

Follow the steps to install Hexo.

Assumptions:
Nodejs is already installed on target system

  1. This will install Hexo CLI on to your system

    1
    npm install hexo-cli -g
  2. On the parent folder where you want to create your setup for your website. let’s say “mywebsite”. This command will create a folder “website” with all the required files and sub-folders

    1
    hexo init website
  3. Initiate and set up

    1
    2
    cd website
    npm install
  4. Start the server

    1
    hexo server

Saving current container in docker

I started a ubuntu container in docker and installed some new packages, edited some files and made it so that I can work with it in the future.

Now it I stop accidently delete the container, all my modifications will be lost.

In order to make sure the modifications are saved and I can reuse the same image as and when I need, you need to save the image in your docker account

1
docker commit <containerid> lalitmehta/<container_name>

Any time you need to pull the saved image and run, follow the following step:

1
docker run -ti --entrypoint=sh --name=<name> -p 8081:80 lalitmehta/<container_name>