在Windows上的Docker容器中运行Artifactory



我正试图在笔记本电脑上本地运行Windows 10上Docker容器中的Artifactory。然而,当我用以下命令启动docker容器时:

docker run--name artifactory-v$env:JFROG_HOME/artifactory/var/:/var/opt/JFROG/artifactory-d-p 8081:8081-p 8082:8082 docker.bintray.io/JFROG/artifactory cpp ce:最新

我尝试访问:http://192.168.17.1/artifactory,我最终得到:

{
"errors" : [ {
"status" : 500,
"message" : "Artifactory failed to initialize: check Artifactory logs for errors."
} ]
}

system.yaml的内容是:

configVersion: 1
shared:
node:
id: 192.168.17.1
ip: 192.168.17.1

和日志:

2020-09-08T20:49:29.438Z [jfrt ] [INFO ] [ee3f97d86edfcb96] [ifactoryApplicationContext:558] [art-init            ] - Artifactory application context set to NOT READY by refresh
2020-09-08T20:49:33.231Z [jfrt ] [WARN ] [ee3f97d86edfcb96] [c.z.h.u.DriverDataSource:70   ] [art-init            ] - Registered driver with driverClassName=org.apache.derby.jdbc.EmbeddedDriver was not found, trying direct instantiation.
2020-09-08T20:49:33.266Z [jfrt ] [INFO ] [ee3f97d86edfcb96] [o.a.s.d.v.DerbyValidator:26   ] [art-init            ] - Validating connection collation for derby database
2020-09-08T20:49:34.537Z [jfrt ] [INFO ] [ee3f97d86edfcb96] [ritiesStorageServiceFactory:25] [art-init            ] - Initializing DB-based Priorities Storage Service
2020-09-08T20:49:35.945Z [jfrt ] [INFO ] [ee3f97d86edfcb96] [actorySchedulerFactoryBean:727] [art-init            ] - Starting Quartz Scheduler now
2020-09-08T20:49:36.004Z [jfrt ] [INFO ] [ee3f97d86edfcb96] [ifactoryApplicationContext:280] [art-init            ] - Artifactory context starting up 47 Spring Beans...
2020-09-08T20:49:36.287Z [jfrt ] [INFO ] [ee3f97d86edfcb96] [o.a.s.a.AccessServiceImpl:459 ] [art-init            ] - Initialized new service id: jfrt@01ehqnp119ag0r0mzvsm9j12dh
2020-09-08T20:49:36.323Z [jfrt ] [INFO ] [ee3f97d86edfcb96] [oryAccessClientConfigStore:608] [art-init            ] - Using Access Server URL: http://localhost:8046/access source: System Config
2020-09-08T20:49:38.191Z [jfrt ] [INFO ] [ee3f97d86edfcb96] [o.j.c.ExecutionUtils:142      ] [pool-23-thread-1    ] - Cluster join: Retry 5: Service registry ping failed, will retry. Error while trying to connect to service registry (status = 404). Please review router request log for additional information
2020-09-08T20:49:43.203Z [jfrt ] [INFO ] [ee3f97d86edfcb96] [o.j.c.ExecutionUtils:142      ] [pool-23-thread-2    ] - Cluster join: Retry 10: Service registry ping failed, will retry. Error while trying to connect to service registry (status = 404). Please review router request log for additional information
2020-09-08T20:49:48.214Z [jfrt ] [INFO ] [ee3f97d86edfcb96] [o.j.c.ExecutionUtils:142      ] [pool-23-thread-1    ] - Cluster join: Retry 15: Service registry ping failed, will retry. Error while trying to connect to service registry (status = 404). Please review router request log for additional information
...
2020-09-08T20:50:58.371Z [jfrt ] [INFO ] [ee3f97d86edfcb96] [o.j.c.ExecutionUtils:142      ] [pool-23-thread-1    ] - Cluster join: Retry 85: Service registry ping failed, will retry. Error while trying to connect to service registry (status = 404). Please review router request log for additional information
2020-09-08T20:51:03.382Z [jfrt ] [ERROR] [ee3f97d86edfcb96] [o.j.c.ExecutionUtils:155      ] [pool-23-thread-2    ] - Cluster join: Service registry ping failed; Error while trying to connect to service registry (status = 404). Please review router request log for additional information
2020-09-08T20:51:03.390Z [jfrt ] [ERROR] [ee3f97d86edfcb96] [ctoryContextConfigListener:126] [art-init            ] - Application could not be initialized: HTTP response status 404:Failed on executing /api/v1/system/ping, with response: Not Found

不确定为什么我们在以下日志中看到localhost:

Using Access Server URL: http://localhost:8046/access source: System Config

为什么它不使用system.yaml中配置的地址192.168.17.1?

我不确定为什么我的设置中一直收到404错误,但我认为这与文件权限有关。JFrog建议我们执行以下命令来运行Docker容器:

mkdir -p $JFROG_HOME/artifactory/var/etc/
cd $JFROG_HOME/artifactory/var/etc/
touch ./system.yaml
chown -R 1030:1030 $JFROG_HOME/artifactory/var
chmod -R 777 $JFROG_HOME/artifactory/var

然后用运行容器

docker run --name artifactory -v $JFROG_HOME/artifactory/var/:/var/opt/jfrog/artifactory -d -p 8081:8081 -p 8082:8082 docker.bintray.io/jfrog/artifactory-<pro|oss|cpp-ce>:latest

然而,由于我在Windows上运行容器,我无法使用touch、chown和chmod执行文件权限的设置。这似乎就是Artifactory无法处理我的设置的原因。当我在没有-v选项的情况下启动Docker容器时,我可以连接到访问URL地址的Artifactory web应用程序http://localhost:8081/artifactory.

我不确定是否有办法在Windows上设置文件权限,以便能够使用-v选项启动容器。

jfrog网站上有一个更简单的方法,它使用一个合适的docker卷,而不是安装一个目录。以下是三个必要步骤:

docker volume create artifactory-data
docker pull releases-docker.jfrog.io/jfrog/artifactory-oss:latest
docker run -d --name artifactory -p 8082:8082 -p 8081:8081 -v artifactory-data:/var/opt/jfrog/artifactory releases-docker.jfrog.io/jfrog/artifactory-oss:latest

当Artifactory完成启动(需要一段时间(后,按照安装后的步骤进行操作。

最新更新