2017-11-14 2 views
0

bazelbuild/rules_docker의 문서에 따르면, OSX에서 이러한 컨테이너 이미지로 작업 할 수 있어야하며, 도커가 없으면 그렇게 할 수 있다고 주장합니다.OSX에서 Bazel 컨테이너 이미지를 실행하는 방법은 무엇입니까?

These rules do not require/use Docker for pulling, building, or pushing images. This means: 

They can be used to develop Docker containers on Windows/OSX without boot2docker or docker-machine installed. 
They do not require root access on your workstation. 

어떻게하면됩니까? 다음은 간단한 규칙이있다 :

go_image(
    name = "helloworld_image", 
    importpath = "github.com/nictuku/helloworld", 
    library = ":go_default_library", 
    visibility = ["//visibility:public"], 
) 

내가 bazel build :helloworld_image으로에게 이미지를 구축 할 수 있습니다. 이 화재 - 빈에서 타르 볼을 생산하지만, 그것을 실행되지 않습니다 : 바보이 OSX 인 리눅스를 실행하려고

INFO: Running command line: bazel-bin/helloworld_image 
Loaded image ID: sha256:08d312b529d30431c68741fd3a31468a02533f27a8c2c29eedc969dae5a39852 
Tagging 08d312b529d30431c68741fd3a31468a02533f27a8c2c29eedc969dae5a39852 as bazel:helloworld_image 
standard_init_linux.go:185: exec user process caused "exec format error" 
ERROR: Non-zero return code '1' from command: Process exited with status 1. 

.

.tar 콘텐츠에서 "도커로드"를 시도했지만 형식이 마음에 들지 않습니다.

 
$ docker load -i bazel-bin/helloworld_image-layer.tar 
open /var/lib/docker/tmp/docker-import-330829602/app/json: no such file or directory 

도움 말? 감사!

답변

1

기본적으로 호스트 플랫폼 용으로 구축하므로 원하는 경우 컨테이너 플랫폼 용으로 빌드해야합니다.

go 바이너리를 사용 중이므로 명령 줄에 --cpu=k8을 지정하여 교차 컴파일을 수행 할 수 있습니다. 이상적으로 우리는 docker 이미지가 리눅스 바이너리를 필요로한다고 말할 수있을 것입니다 (그래서 --cpu 명령 행 플래그를 지정할 필요가 없습니다). 그러나 이것은 여전히 ​​Bazel에서 진행중인 작업입니다.

관련 문제