如何使用现有的图像复制容器

我已经遵循这个答案( 复制docker容器debugging ),但即使执行第一行代码:

docker run -it <base_image> /bin/bash 

我得到这样的错误:docker:来自守护进程的错误响应:找不到。 参见“docker运行 – 帮助”。

我猜上面的代码是基于现有的图像创build新的容器。 然后按照以下两行代码:

 yum install ping docker commit <hash tag of running container> new_image 

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

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

但对于我来说,克隆magento / maraidb容器后,我仍然希望他们使用相同的图像文件。 (只需在{{.Config.Env}}中更改一些configuration

——–更新: – 现在我不介意保存对新图像的更改,并在新容器上创build容器—————-

我遵循你的build议,并确保docker守护进程正在运行。 我也做了第一个通过:

 docker pull bitnami/mariadb:latest docker pull bitnami/magento:latest 

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

 docker commit {container A}bitnami/mariadb:newname docker commit {container B} bitnami/magento:newname 

然后,如果我使用新的图像“Docker运行….”,我得到这个错误:

  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") 

——– UPDATE2: – 也许以前我可能没有说清楚。 这是我的步骤:—————-

1,使用docker-compose和docker-compose.yml创build1个Magento&MariaDB容器。 图像是: magento:最新mariadb:最新

2,然后我login到Magento,并做了很less的系统更改。 接下来我想要的是创build/导出/提交当前容器到新的图像,例如叫他们magento:sammariadb:山姆 。 我使用的命令是:docker commit {container id} magento:sam

3,在上一步之前,我还使用了:docker pull magento:最新的 (我听从别人的build议,因为他们说有些数据可能不能存储在容器中,需要先拉 – 如果是错的,请指出。

4,创build新图像后,我使用:docker -ti -p 81:81 magento:sam尝试根据新图像创build新的容器。 但是获取消息和错误消息为:

 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** 

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

如这里所见 ,这意味着docker工正在寻找你的基础图像,但没有find它。

检查你的docker守护进程是如何启动的,并确保你想克隆的基础镜像是docker pull (在本地registry中)。
当然,请用正确的图像名称replace<base_image>