你可以在构建自定义映像时设置映像名称,如下所示:

docker build -t dude/man:v2 . # Will be named dude/man:v2

是否有一种方法可以在Dockerfile中定义图像的名称,这样我就不必在docker构建命令中提到它了?

我不知道什么时候应该使用CMD vs RUN。例如,要执行bash/shell命令(即ls -la),我总是使用CMD,或者有一种情况下我会使用RUN?试图理解这两个类似Dockerfile指令的最佳实践。

我正在写一个Dockerfile。有办法在这个文件中做注释吗?

Docker是否有一个注释选项来接受一行的剩余部分并忽略它?

我一直在阅读和学习Docker,并试图正确选择要使用的Django设置。到目前为止,有两种:

Docker撰写或Dockerfile

我知道Dockerfile在Docker Compose中使用,但我不确定将所有内容放在一个大Dockerfile中,对不同的图像使用多个FROM命令是否是个好做法?

我想使用几个不同的图像,包括:

uwsgi
nginx
postgres
redis
rabbitmq
celery with cron

请建议使用Docker建立这种类型环境的最佳实践是什么。

如果有帮助,我在Mac上,所以使用boot2docker。

我遇到的一些问题:

Docker Compose与Python3不兼容 我想容器化我的项目,所以如果一个大Dockerfile 是不理想的,那么我觉得我需要打破它使用Docker撰写 我可以让项目Py2和Py3兼容,所以我倾向于django-compose

我正在用Python文本阅读Sweigart的《自动化无聊的东西》。我正在使用IDLE,并且已经安装了Selenium模块和Firefox浏览器。

每当我试图运行webdriver函数,我得到这个:

from selenium import webdriver
browser = webdriver.Firefox()

例外:

Exception ignored in: <bound method Service.__del__ of <selenium.webdriver.firefox.service.Service object at 0x00000249C0DA1080>>
Traceback (most recent call last):
  File "C:\Python\Python35\lib\site-packages\selenium\webdriver\common\service.py", line 163, in __del__
    self.stop()
  File "C:\Python\Python35\lib\site-packages\selenium\webdriver\common\service.py", line 135, in stop
    if self.process is None:
AttributeError: 'Service' object has no attribute 'process'
Exception ignored in: <bound method Service.__del__ of <selenium.webdriver.firefox.service.Service object at 0x00000249C0E08128>>
Traceback (most recent call last):
  File "C:\Python\Python35\lib\site-packages\selenium\webdriver\common\service.py", line 163, in __del__
    self.stop()
  File "C:\Python\Python35\lib\site-packages\selenium\webdriver\common\service.py", line 135, in stop
    if self.process is None:
AttributeError: 'Service' object has no attribute 'process'
Traceback (most recent call last):
  File "C:\Python\Python35\lib\site-packages\selenium\webdriver\common\service.py", line 64, in start
    stdout=self.log_file, stderr=self.log_file)
  File "C:\Python\Python35\lib\subprocess.py", line 947, in __init__
    restore_signals, start_new_session)
  File "C:\Python\Python35\lib\subprocess.py", line 1224, in _execute_child
    startupinfo)
FileNotFoundError: [WinError 2] The system cannot find the file specified

在处理上述异常时,发生了另一个异常:

Traceback (most recent call last):
  File "<pyshell#11>", line 1, in <module>
    browser = webdriver.Firefox()
  File "C:\Python\Python35\lib\site-packages\selenium\webdriver\firefox\webdriver.py", line 135, in __init__
    self.service.start()
  File "C:\Python\Python35\lib\site-packages\selenium\webdriver\common\service.py", line 71, in start
    os.path.basename(self.path), self.start_error_message)
selenium.common.exceptions.WebDriverException: Message: 'geckodriver' executable needs to be in PATH.

我想我需要为geckodriver设置路径,但我不确定如何,所以我该如何做到这一点?

我正在按照这个链接创建我的第一个docker映像,它成功了,现在我试图从这个链接将这个映像推到我的docker存储库中。但是每当我试图将这个映像推入存储库时,我就会得到这种类型的错误。

denied: requested access to the resource is denied

注:我已成功登录docker

我刚刚生成了RSA密钥对,我想将该密钥添加到GitHub。

我尝试了cd id_rsa.pub和id_rsa.php,但没有成功。如何访问SSH公钥?

我需要为GitHub做SSH密钥审计,但我不确定如何找到我的RSA密钥指纹。我最初是按照指南在Linux上生成SSH密钥的。

我需要输入什么命令来查找我当前的RSA密钥指纹?

如何从容器访问外部数据库?在连接字符串中硬编码是最好的方法吗?

# Dockerfile
ENV DATABASE_URL amazon:rds/connection?string

Dockerfile中的COPY和ADD命令有什么区别?我什么时候可以使用其中一个命令而不是另一个命令?

COPY <src> <dest>

COPY指令将从<src>复制新文件,并将它们添加到路径<dest>的容器文件系统中

ADD <src> <dest>

ADD指令将从<src>复制新文件,并将它们添加到路径<dest>的容器文件系统中。