我有以下docker-compose.yml文件:
version: '3'
services:
maria_service:
build: ./db_maria
restart: always
environment:
MYSQL_DATABASE: mariadb
MYSQL_USER: joel
MYSQL_PASSWORD: password
MYSQL_ROOT_PASSWORD: password
volumes:
- ./db:/var/lib/mysql
drupal_service:
build: ./website
restart: always
ports:
- 8080:80
volumes:
- /var/www/html/modules
- /var/www/html/profiles
- /var/www/html/themes
# this takes advantage of the feature in Docker that a new anonymous
# volume (which is what we're creating here) will be initialized with the
# existing content of the image at the same location
- /var/www/html/sites
depends_on:
- maria_service
Run Code Online (Sandbox Code Playgroud)
这是我的工作目录: …
我有一个源代码,我想使用 Dockerfile 将其添加到 docker 镜像中。我使用 COPY 命令,但我不知道应该在目标位置放置什么。你能告诉我目标是一个特定的目录还是可选的?
我想使用 Docker 创建一个容器,它将负责根据每当 gem 的配置启动重复的 rake 任务。我有一个普通的 ruby 项目(没有 Rails/sinatra),其结构如下:
宝石文件:
source 'https://rubygems.org'
gem 'rake', '~> 12.3', '>= 12.3.1'
gem 'whenever', '~> 0.9.7', require: false
group :development, :test do
gem 'byebug', '~> 10.0', '>= 10.0.2'
end
group :test do
gem 'rspec', '~> 3.5'
end
Run Code Online (Sandbox Code Playgroud)
config/schedule.rb : (无论何时配置)
ENV.each { |k, v| env(k, v) }
every 1.minutes do
rake 'hello:start'
end
Run Code Online (Sandbox Code Playgroud)
lib/tasks/hello.rb : (rake 配置)
namespace :hello do
desc 'This is a sample'
task :start do
puts 'start something!'
end …Run Code Online (Sandbox Code Playgroud) 我有一个 dockerfile
\n\n\n\nFROM alpine:3.7\n\nRUN apk --no-cache add\nphp7\nphp7-fpm\nphp7-pdo\nphp7-pdo_mysql\nphp7-mcrypt\nphp7-mbstring\nphp7-xml\nphp7-openssl\nphp7-json\nphp7-phar\nphp7-zip\nphp7-dom\nphp7-session\nphp7-zlib &&\nphp7 -r "copy(\'http://getcomposer.org/installer\', \'composer-setup.php\');" &&\nphp7 composer-setup.php --install-dir=/usr/bin --filename=composer &&\nphp7 -r "unlink(\'composer-setup.php\');" &&\nln -sf /usr/bin/php7 /usr/bin/php &&\nln -s /etc/php7/php.ini /etc/php7/conf.d/php.ini\n\nRUN set -x\n&& addgroup -g 82 -S www-data\n&& adduser -u 82 -D -S -G www-data www-data\n\nCOPY . /src\nADD .env.example /src/.env\nWORKDIR /src\nRUN ["/bin/sh", "-c"," php artisan key:generate"]\nRUN chmod -R 777 storage\nCMD php artisan serve --host=0.0.0.0\nRun Code Online (Sandbox Code Playgroud)\n\n在运行它的过程中,我不断得到
\n\nCreating network "portal-modules_default" with the default driver \nBuilding fingerprinting \n> ERROR: Dockerfile parse error line 4: …Run Code Online (Sandbox Code Playgroud) 我在互联网上阅读了大量资源,但没有明确指出这一点。有人可以澄清 docker 容器在启动时是否从主机选择时间和时区吗?
换句话说,添加的目的是什么
CMD ["/bin/bash"]
Run Code Online (Sandbox Code Playgroud)
在 dockerfile 中?
我有一个 dockerfile 以前有以下两行
FROM ubuntu:16.04
...
CMD ["/bin/bash"]
Run Code Online (Sandbox Code Playgroud)
最后我需要CMD吗?目的是什么?
我在项目的根目录上有一个文件,我打开它是这样的:
file, err := os.Open("file.csv")
Run Code Online (Sandbox Code Playgroud)
当我go run main.go让它工作时。当我使用 dockerfile 运行应用程序时,它不起作用:
打开 file.csv:没有这样的文件或目录
我的 dockerfile 是这样的:
FROM golang:alpine as builder
RUN mkdir /build
ADD . /build/
WORKDIR /build
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -ldflags '-extldflags "-static"' -o main .
FROM scratch
COPY --from=builder /build/main /app/
WORKDIR /app
CMD ["./main"]
Run Code Online (Sandbox Code Playgroud)
我不习惯 dockerfiles,所以也欢迎任何即兴表演!
我对 docker 文件了解不多。请帮助我满足以下要求。
我正在寻找一个 docker RUN 命令,如下所示:
RUN set -ex && \
yum install -y tar gzip && \
<Other set of commands which includes mkdir, curl, tar>
rm -vr properties && \
if [${arg} == "prod"] then rm -v conf/args.properties fi
Run Code Online (Sandbox Code Playgroud)
这不起作用并出现错误
syntax error: unexpected end of file
我正在尝试Nginx使用apline:latest图像创建自己的图像,在修复了很多错误之后,多亏了互联网,我设法做到了并且一切正常,但是问题是当我运行以下命令时:
rc-service nginx status
* status: stopped
Run Code Online (Sandbox Code Playgroud)
当我尝试启动服务时,这就是它给我的内容,如下所示:
rc-service nginx start
* WARNING: nginx is already starting
Run Code Online (Sandbox Code Playgroud)
即使服务停止,第二个命令的输出告诉它已经启动?!
于是我打开了我的docker-machine的localhost来验证服务是开启还是关闭,成功出现nginx html页面。
我尝试运行rc-service nginx reload,结果如下:
rc-service nginx reload
/lib/rc/sh/openrc-run.sh: line 100: can't create /sys/fs/cgroup/blkio/tasks: Read-only file system
/lib/rc/sh/openrc-run.sh: line 100: can't create /sys/fs/cgroup/cpu/tasks: Read-only file system
/lib/rc/sh/openrc-run.sh: line 100: can't create /sys/fs/cgroup/cpuacct/tasks: Read-only file system
/lib/rc/sh/openrc-run.sh: line 100: can't create /sys/fs/cgroup/cpuset/tasks: Read-only file system
/lib/rc/sh/openrc-run.sh: line 100: can't create /sys/fs/cgroup/devices/tasks: Read-only file system
/lib/rc/sh/openrc-run.sh: line 100: …Run Code Online (Sandbox Code Playgroud)