首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何使用现有映像复制容器

如何使用现有映像复制容器
EN

Stack Overflow用户
提问于 2017-03-28 04:15:49
回答 1查看 1.9K关注 0票数 1

我遵循了这个答案(Duplicating docker container for debugging),但即使在执行第一行代码时:

代码语言:javascript
复制
docker run -it <base_image> /bin/bash

我得到了这样的错误: docker:来自守护进程的错误响应: Not。参见“docker run --help”。

我猜上面的代码是根据现有的图像创建新的容器。然后,下面是2行代码:

代码语言:javascript
复制
yum install ping 
docker commit <hash tag of running container> new_image

他们将ping工具安装到新容器中,然后将其作为新映像导出。

如果我以前的理解是不正确的,请纠正我。

但是对于我来说,在克隆magento/maraidb容器之后,我仍然希望它们使用相同的图像文件。(只需更改{{.Config.Env}中的某些配置即可)

我遵循您的建议,并确保docker守护进程正在运行。我也是第一次通过:

代码语言:javascript
复制
docker pull bitnami/mariadb:latest
docker pull bitnami/magento:latest

由于我仍然需要将容器中的所有这些更改导出到新映像中,所以我这样做了:

代码语言:javascript
复制
docker commit {container A}bitnami/mariadb:newname
docker commit {container B} bitnami/magento:newname

然后,如果我使用新图像作为“Docker run.”,则会得到以下错误:

代码语言:javascript
复制
 INFO  ==> Starting mysqld_safe...
mariadb_1 | Could not open required defaults file: /opt/bitnami/mariadb/conf/my.cnf
mariadb_1 | Fatal error in defaults handling. Program aborted
mariadb_1 | WARNING: Defaults file '/opt/bitnami/mariadb/conf/my.cnf' not found!
mariadb_1 | Could not open required defaults file: /opt/bitnami/mariadb/conf/my.cnf
mariadb_1 | Fatal error in defaults handling. Program aborted
mariadb_1 | WARNING: Defaults file '/opt/bitnami/mariadb/conf/my.cnf' not found!
mariadb_1 | 170330 00:04:40 mysqld_safe Logging to '/opt/bitnami/mariadb/data/4bdcd2db9267.err'.
mariadb_1 | 170330 00:04:40 mysqld_safe Starting mysqld daemon with databases from /opt/bitnami/mariadb/data
mariadb_1 | /opt/bitnami/mariadb/bin/mysqld_safe_helper: Can't create/write to file '/opt/bitnami/mariadb/data/4bdcd2db9267.err' (Errcode: 2 "No such file or directory")

这是我的步骤:-

1,使用docker-compose.yml创建一个Magento & MariaDB容器。这些图像是:magento:latest和mariadb:latest

2 .然后登录到Magento,进行了很少的系统更改。接下来我想要的是创建/导出/提交当前容器到新映像,例如,将它们命名为mariadb:sam. magento:sam和我使用的命令是: docker提交{容器id} magento:sam.

3,在前面的步骤之前,我还使用了: docker magento:latest (我听从了其他人的建议,因为他们说有些数据可能不会存储在容器中,需要首先提取-如果是错的,请指出)。

4 .在创建新映像之后,我使用: docker -ti -p 81:81 magento:sam尝试创建基于新映像的新容器。但是,获取消息和错误消息的步骤如下:

代码语言:javascript
复制
Welcome to the magento image ***
Brought to you by Bitnami ***
More information: https://github.com/bitnami/bitnami-docker-magento ***
Issues: https://github.com/bitnami/bitnami-docker-magento/issues ***

New version available: run docker pull bitnami/magento:2.1.5-r2 to update. ***

**nami ERROR Unable to start com.bitnami.apache: httpd: Could not open configuration file /opt/bitnami/apache/conf/httpd.conf: No such file or directory**

请帮助哪一步是错误的或遗漏任何步骤。再次感谢!

EN

回答 1

Stack Overflow用户

发布于 2017-03-28 05:02:36

As seen here,这意味着码头正在寻找你的基本形象,但找不到它。

检查您的停靠守护进程是如何启动的,并确保您希望首先克隆的基本映像是docker pull (在本地注册表中)。

当然,请将<base_image>替换为正确的图像名称。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/43060542

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档