Cannot npm publish a package: DEPTH_ZERO_SELF_SIGNED_CERT failed, reason: self signed certificate

I installed GitLab locally on Ubuntu 20.04 using docker.
Here is my docker-compose.yml:

version: '3.7'
    image: 'gitlab/gitlab-ce:latest'
    restart: always
    hostname: ''
        external_url ''
      - '80:80'
      - '443:443'
      - '22:22'
      - '$GITLAB_HOME/config:/etc/gitlab'
      - '$GITLAB_HOME/logs:/var/log/gitlab'
      - '$GITLAB_HOME/data:/var/opt/gitlab'

To access the domain, I added it to the /etc/hosts.

Now I can connect to the gitlab using browser and everythings goes fine.

The problem is that I cannot publish my NPM package.

I did configure project-specific auth and npm using corresponding docs:

$ npm config set @foo:registry<your_project_id>/packages/npm/
$ npm config set -- '//<your_project_id>/packages/npm/:_authToken' "<your_token>"

but now when I publish the package I get the following error:

$ npm publish
 npm ERR! request to failed, reason: self signed certificate

I also tried to use plain HTTP url for the external_host variable, but it lead to another error:

npm ERR! network request to failed, reason: Client network socket disconnected before secure TLS connection was established

Any ideas what’s wrong?