使用WordPress php-apache-7.4作为基本图像,我创建了一个具有很少自定义的Docker文件,并创建了一个图像。我正在使用同一docker-entrypoint.sh,wp-config-docker.php文件中的docker Hub官方图像。
-
在我在Docker桌面上创建一个容器时使用图像,它可以正常工作,我可以加载WP页
-
我将同一图像上传到Docker Hub并从那里,并使用该图像在EKS群集上创建了一个POD,我接收到错误“ exec/usr/local/bin/docker-entrypoint.sh:exec格式错误。”
我正在使用以下存储库中的文件
仅修改上述存储库中的Docker文件,已修改以安装Memcached并复制WP-Config.php。我使用的其他两个文件没有任何更改。
我尝试更改docker-entrypoint.sh脚本以添加#!/bin/bash
,如某些问题所述,我也尝试创建一个custom-entrypoint.sh来编辑原始docker-entrypoint .SH脚本在另一页中也建议,但它们没有起作用。
custom-entrypoint.sh
#!/bin/bash
sed -i -e 's/^exec "$@"/#exec "$@"/g' /usr/local/bin/docker-entrypoint.sh
source docker-entrypoint.sh
exec "$@"
试图解决此问题,唯一的事情是令人困惑的是,当我使用相同的图像创建它运行cont而没有任何错误时,在docker桌面上。
-
Using WordPress php-apache-7.4 as base image, I created a Docker file with few customisation and created an image. I am using the same docker-entrypoint.sh, wp-config-docker.php files from the Docker Hub official image.
-
Using the image when I create a container on Docker Desktop it works fine and I am able to load the WP page
-
I upload the same image to Docker Hub and from there and using that image created a pod on EKS cluster and I receive the error "exec /usr/local/bin/docker-entrypoint.sh: exec format error."
I am using the files from the below repo
https://github.com/docker-library/wordpress/tree/3b5c63b5673f298c14142c0c0e3e51edbdb17fd3/latest/php7.4/apache
Only Docker file in the above repo is modified to installed the memcached and copy wp-config.php. The other two files I am using without any changes.
I tried changing the docker-entrypoint.sh script to add #!/bin/bash
as mentioned in some issue reported, also I tried to create a custom-entrypoint.sh to edit the original docker-entrypoint.sh script which was also suggested in another page but they didn't work.
custom-entrypoint.sh
#!/bin/bash
sed -i -e 's/^exec "$@"/#exec "$@"/g' /usr/local/bin/docker-entrypoint.sh
source docker-entrypoint.sh
exec "$@"
Trying to fix this, only thing is confusing is on Docker Desktop when I create using the same image it runs the cont without any error.
发布评论
评论(1)
正如David Maze上面的评论中提到的那样,问题归因于Mac M1 Pro上的图像。
时运行以下命令。
要解决此问题,我需要从-platform = linux/amd64< image> - < version> 添加
,或者您可以在运行构建
docker build --platform = linux/amd64< image> - <版本>
两个解决方案都可以使用。我从-platform = linux/amd64 添加到dockerfile,现在已修复。
As mentioned in the comment above by David Maze, the issue is due to building the image on Mac M1 Pro.
To fix this I need to add
FROM --platform=linux/amd64 <image>-<version>
in the Dockerfile and build or you can run the below command while running the builddocker build --platform=linux/amd64 <image>-<version>
Both solutions will work. I added
FROM --platform=linux/amd64
to the Dockerfile and it's fixed now.