Tag Archives: docker

[Solved] CentOS 6 yum update Error: Cannot find a valid baseurl for repo: base

Error Message:
Loaded plugins: fastestmirror, ovl
Setting up Update Process
Loading mirror speeds from cached hostfile
YumRepo Error: All mirror URLs are not using ftp, http[s] or file.
Eg. Invalid release/repo/arch combination/
removing mirrorlist with no valid mirrors: /var/cache/yum/x86_64/6/base/mirrorlist.txt
Error: Cannot find a valid baseurl for repo: base

Solution:

mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.old  #Backup
vi /etc/yum.repos.d/CentOS-Base.repo   #New

/etc/yum.repos.d/centos-base.repo

[base]
name=CentOS-$releasever - Base
baseurl=https://vault.centos.org/6.10/os/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6

[updates]
name=CentOS-$releasever - Updates
baseurl=https://vault.centos.org/6.10/updates/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6

[extras]
name=CentOS-$releasever - Extras
baseurl=https://vault.centos.org/6.10/extras/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6

[Solved] Docker Error: Error response from daemon: driver failed programming external connectivity on endpoint

Error Message:

docker: Error response from daemon: driver failed programming external connectivity on endpoint kibana (16b783b436c6fc895f51866efea8a25c5748f7b3a78db1ec2cb0364e28e7feef): (iptables failed: iptables –wait -t nat -A DOCKER -p tcp -d 0/0 –dport 5601 -j DNAT –to-destination 172.17.0.4:5601 ! -i docker0: iptables: No chain/target/match by that name.
(exit status 1)).

Solution:
Docker reboot
You can register the iptables chain
Restart the Docker container

systemctl restart docker

How to Solve Docker Run Error: standard_init_linux.go:219: exec user process caused: exec format error

Use MAC M1 build image to run on Linux and report standard_ init_ linux.go:219: exec user process caused: exec format error

The main reason for this problem is that golang compilation cannot cross platform, that is, different systems or different CPU cores will cause this error. The golang code compiled under Linux arm cannot be run under Linux x86; Similarly, the image of a project with golang code cannot cross platform. The solution is very simple. When building, add the — platform Linux/AMD64 parameter

docker build --platform linux/amd64 -t tag .

[Solved] Docker Error: SyntaxError: Non-ASCII character ‘\xe5‘ in file xxx

Problem description

Use the following docker command to temporarily run the image: (XXX is a python file)

sudo docker run -it --rm -p 8888:8888 xxx

report errors:

SyntaxError: Non-ASCII character '\xe5' in file xxx on line 1, but no encoding declared; see http://python.org/dev/peps/pep-0263/ for details

Cause analysis

Unsupported character sets may be included when packaging docker images.

Solution

In the first line of dockerfile, add:

ENV LANG C.UTF-8

[Solved] Error(22) WARNING: IPv4 forwarding is disabled. Networking will not work.

Question

The following warning is given when docker runs the container ⚠️:

WARNING: IPv4 forwarding is disabled. Networking will not work.

Solution:

# modify configuration
echo "net.ipv4.ip_forward=1" >> /etc/sysctl.conf

# restart network
systemctl restart network

# Check
sysctl net.ipv4.ip_forward
# net.ipv4.ip_forward = 1

# restart docker
systemctl restart docker

Then restart the container ^_^

The docker export container cannot be run after being imported: error response from daemon: no command specified

The docker export container cannot be run after being imported. An error is reported: error response from daemon: no command specified

According to the error message, the command can be run without specifying the command

[root@localhost ~]# docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
docker.io/ubuntu    latest              fb52e22af1b0        3 weeks ago         72.8 MB

[root@localhost ~]# docker run -itd docker.io/ubuntu:latest
7ce403eba8d89127395e057eb4d6cf7eb2374e40214ce6575a29e755b707ca23

[root@localhost ~]# docker ps
CONTAINER ID        IMAGE                     COMMAND             CREATED             STATUS              PORTS               NAMES
7ce403eba8d8        docker.io/ubuntu:latest   "bash"              4 seconds ago       Up 3 seconds                            hungry_babbage
[root@localhost ~]# docker export -o test.tar 7ce403eba8d8

[root@localhost ~]# ls
anaconda-ks.cfg  test.tar

[root@localhost ~]# docker import test.tar test/ubuntu:v0.1
sha256:c3d604273769f7a74126b27f29c8cecd055fc18b10c943da0c0528dc28520a60

[root@localhost ~]# docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
test/ubuntu         v0.1                c3d604273769        4 seconds ago       72.8 MB
docker.io/ubuntu    latest              fb52e22af1b0        3 weeks ago         72.8 MB

[root@localhost ~]# docker run -itd test/ubuntu:v0.1
/usr/bin/docker-current: Error response from daemon: No command specified.
See '/usr/bin/docker-current run --help'.

# add /bin/bash work
[root@localhost ~]# docker run -itd test/ubuntu:v0.1 /bin/bash
5b7dca448a1400716fa931463c2c314e0e59c7888fa77d5b182e72d911122966

[root@localhost ~]# docker ps
CONTAINER ID        IMAGE                     COMMAND             CREATED             STATUS              PORTS               NAMES
5b7dca448a14        test/ubuntu:v0.1          "/bin/bash"         3 seconds ago       Up 2 seconds                            zen_varahamihira
7ce403eba8d8        docker.io/ubuntu:latest   "bash"              5 minutes ago       Up 5 minutes                            hungry_babbage

ERROR Docker Engine API on Mac Osx

    according to the official document docker desktop on MAC vs. docker toolbox, docker desktop on Mac only provides UNIX socket/var/run/docker.socket, and does not provide TCP listening (default 2375 port). If you configure host in docker desktop using the configuration method of Linux, Docker desktop cannot be started. You need to delete the hosts configuration in ~ /. Docker/daemon.json to start normally. The following method exposes 2375 TCP

    docker run --rm -d -v /var/run/docker.sock:/var/run/docker.sock -p 127.0.0.1:2375:2375 bobrik/socat TCP-LISTEN:2375,fork UNIX-CONNECT:/var/run/docker.sock
    
      then view the current docker engine version through docker version, such as 1.40. View the official engine API document: https://docs.docker.com/engine/api Search for an image to test:

      $curl -XGET http://127.0.0.1:2375/version | python -mjson.tool
      
      {
          "ApiVersion": "1.41",
          "Arch": "amd64",
          "BuildTime": "2021-07-30T19:52:10.000000000+00:00",
          "Components": [
              {
                  "Details": {
                      "ApiVersion": "1.41",
                      "Arch": "amd64",
                      "BuildTime": "2021-07-30T19:52:10.000000000+00:00",
                      "Experimental": "false",
                      "GitCommit": "75249d8",
                      "GoVersion": "go1.16.6",
                      "KernelVersion": "5.10.47-linuxkit",
                      "MinAPIVersion": "1.12",
                      "Os": "linux"
                  },
                  "Name": "Engine",
                  "Version": "20.10.8"
              },
              {
                  "Details": {
                      "GitCommit": "e25210fe30a0a703442421b0f60afac609f950a3"
                  },
                  "Name": "containerd",
                  "Version": "1.4.9"
              },
              {
                  "Details": {
                      "GitCommit": "v1.0.1-0-g4144b63"
                  },
                  "Name": "runc",
                  "Version": "1.0.1"
              },
              {
                  "Details": {
                      "GitCommit": "de40ad0"
                  },
                  "Name": "docker-init",
                  "Version": "0.19.0"
              }
          ],
          "GitCommit": "75249d8",
          "GoVersion": "go1.16.6",
          "KernelVersion": "5.10.47-linuxkit",
          "MinAPIVersion": "1.12",
          "Os": "linux",
          "Platform": {
              "Name": "Docker Engine - Community"
          },
          "Version": "20.10.8"
      }
      

[Solved] Docker compose error: ERROR: Encountered errors while bringing up the project.

Error running docker compose file:

ERROR: for yingxue_mysql_1  Cannot create container for service mysql: invalid volume specification: 'yingxue_data:var/lib/mysql:rw': invalid mount config for type "volume": invalid mount path: 'var/lib/mysql' mount path must be absolute

ERROR: for mysql  Cannot create container for service mysql: invalid volume specification: 'yingxue_data:var/lib/mysql:rw': invalid mount config for type "volume": invalid mount path: 'var/lib/mysql' mount path must be absolute
ERROR: Encountered errors while bringing up the project.

Docker compose original file

version: "3.3"

networks:
  yingxue_network:

volumes: 
  data:

services:
  nacos:
    image: nacos/nacos-server:2.0.2
    ports:
      - "8848:8848"
    environment:
      - "JVM_XMS=256m"
      - "JVM_XMX=256m"
      - "MODE=standalone"
    networks:
      - yingxue_network

  mysql:
    image: mysql:5.7
    ports:
      - "3306:3306"
    networks:
      - yingxue_network
    volumes:
      - data:var/lib/mysql
      - ./yingxue.sql:/docker-entrypoint-initdb.d/yingxue.sql
    environment:
      - "MYSQL_ROOT_PASSWORD=root"
      - "MYSQL_DATABASE=yingxue"

The problem description shows that the path is wrong. After careful inspection, it is found that the data volume data: var/lib/MySQL is missing /, which should be:

    volumes:
      - data:/var/lib/mysql
      - ./yingxue.sql:/docker-entrypoint-initdb.d/yingxue.sql

[Solved] Error during composer operation in docker: insufficient memory

Background
Need to perform composer removal package operation on lumen framework.
Error message

docker composer remove Fatal error: Allowed memory size of 1610612736 bytes exhausted (tried to allocate 4096 byt

Solution:

/usr/local/bin/php -d memory_limit=-1 /usr/local/sbin/composer remove xxx

Explanation: php -d memory_limit=-1 means that the php process uses unlimited memory.
Note that both php and composer need to use absolute paths.