[英]Copy folder in docker entrypoint sh script produces wrong folder name
I have a small docker based project and I want to copy my local.ssh folder inside then modify folder permissions.我有一个基于 docker 的小项目,我想复制我的 local.ssh 文件夹,然后修改文件夹权限。
Unfortunately there is something wrong with my.sh script because the folder's name what it creates in /root looks like this: '.ssh'$'\r'不幸的是,my.sh 脚本有问题,因为它在 /root 中创建的文件夹名称如下所示: '.ssh'$'\r'
docker-compose.yml: docker-compose.yml:
version: '3.7'
services:
sandbox:
build:
context: ./
dockerfile: ./Dockerfile
volumes:
- .:/var/www/html
- ~/.ssh:/tmp/.ssh
restart: always
ports:
- "8060:80"
environment:
- APACHE_RUN_DIR=/var/run/apache2
- APACHE_RUN_USER=#1000
- APACHE_RUN_GROUP=#1000
- APACHE_LOG_DIR=/var/log/apache2
- APACHE_PID_FILE=/tmp/apache2.pid
- APACHE_LOCK_DIR=/var/lock/apache2
- JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64
Dockerfile: Dockerfile:
FROM php:7.4.1-apache-buster
RUN echo "ServerName localhost" >> /etc/apache2/apache2.conf
RUN a2enmod rewrite
COPY vhost-configs/vhost.local.conf /etc/apache2/sites-available/
COPY vhost-configs/vhost.local.conf /etc/apache2/sites-enabled/
RUN rm /etc/apache2/sites-enabled/000-default.conf
EXPOSE 80
COPY docker-entrypoint.sh /bin/docker-entrypoint.sh
RUN chmod 777 /bin/docker-entrypoint.sh && chmod +x /bin/docker-entrypoint.sh
CMD /usr/sbin/apache2 -DFOREGROUND
ENTRYPOINT ["sh", "/bin/docker-entrypoint.sh"]
docker-entrypoint.sh: docker-入口点.sh:
#!/bin/sh -e
cp -R /tmp/.ssh /root/.ssh
chmod 700 /root/.ssh
chmod 400 /root/.ssh/id_rsa
exec "$@"
The docker-entrypoint.sh file was created on windows and contained dos line endings. docker-entrypoint.sh 文件创建于 windows 并包含 dos 行结尾。
I installed dos2unix and converted the file inside the container:我安装了 dos2unix 并在容器内转换了文件:
RUN apt-get install -y dos2unix
RUN dos2unix /bin/docker-entrypoint.sh
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.