Bagikan melalui


definisi jobs.job.container

Pekerjaan kontainer memungkinkan Anda menjalankan pekerjaan pada kontainer alih-alih host agen.

Definisi yang mereferensikan definisi ini: pipeline, jobs.job, jobs.deployment

Definisi yang mereferensikan definisi ini: alur, jobs.job

Implementasi

Penerapan Deskripsi
kontainer: string Tentukan kontainer pekerjaan menurut alias.
kontainer: gambar Tentukan kontainer pekerjaan menggunakan tag dan opsi gambar.

kontainer: string

Tentukan kontainer pekerjaan menurut alias.

container: string # Specify job container by alias.

container String.

Tentukan kontainer pekerjaan menurut alias.

Keterangan

Alias dapat menjadi nama gambar, atau dapat menjadi referensi ke sumber daya kontainer.

Contoh

Contoh berikut mengambil gambar ubuntu yang ditandai 18.04 dari Docker Hub lalu memulai kontainer. printenv Ketika perintah berjalan, itu terjadi di dalam kontainer ubuntu:18.04.

pool:
  vmImage: 'ubuntu-18.04'

container: ubuntu:18.04

steps:
- script: printenv

kontainer: gambar

Tentukan kontainer pekerjaan menggunakan tag dan opsi gambar.

container:
  image: string # Required. Container image tag.
  endpoint: string # ID of the service endpoint connecting to a private container registry.
  env: # Variables to map into the container's environment.
    string: string # Name/value pairs
  mapDockerSocket: boolean # Set this flag to false to force the agent not to setup the /var/run/docker.sock volume on container jobs.
  options: string # Options to pass into container host.
  ports: [ string ] # Ports to expose on the container.
  volumes: [ string ] # Volumes to mount on the container.
  mountReadOnly: # Volumes to mount read-only, the default is all false.
    work: boolean # Mount the work directory as readonly.
    externals: boolean # Mount the externals directory as readonly.
    tools: boolean # Mount the tools directory as readonly.
    tasks: boolean # Mount the tasks directory as readonly.

Properti

image String. Wajib diisi.
Tag gambar kontainer.

endpoint String.
ID titik akhir layanan yang terhubung ke registri kontainer privat.

env kamus string.
Variabel untuk dipetakan ke lingkungan kontainer.

mapDockerSocketboolean.
Atur bendera ini ke false untuk memaksa agen untuk tidak mengatur volume /var/run/docker.sock pada pekerjaan kontainer.

options String.
Opsi untuk masuk ke host kontainer.

ports daftar string.
Port untuk diekspos pada kontainer.

volumes daftar string.
Volume yang akan dipasang pada kontainer.

mountReadOnlymountReadOnly.
Volume untuk memasang baca-saja, defaultnya adalah false.

kontainer: gambar

Tentukan kontainer pekerjaan menggunakan tag dan opsi gambar.

container:
  image: string # Required. Container image tag.
  endpoint: string # ID of the service endpoint connecting to a private container registry.
  env: # Variables to map into the container's environment.
    string: string # Name/value pairs
  mapDockerSocket: boolean # Set this flag to false to force the agent not to setup the /var/run/docker.sock volume on container jobs.
  options: string # Options to pass into container host.
  ports: [ string ] # Ports to expose on the container.
  volumes: [ string ] # Volumes to mount on the container.

Properti

image String. Wajib diisi.
Tag gambar kontainer.

endpoint String.
ID titik akhir layanan yang terhubung ke registri kontainer privat.

env kamus string.
Variabel untuk dipetakan ke lingkungan kontainer.

mapDockerSocketboolean.
Atur bendera ini ke false untuk memaksa agen untuk tidak mengatur volume /var/run/docker.sock pada pekerjaan kontainer.

options String.
Opsi untuk masuk ke host kontainer.

ports daftar string.
Port untuk diekspos pada kontainer.

volumes daftar string.
Volume yang akan dipasang pada kontainer.

kontainer: gambar

Tentukan kontainer pekerjaan menggunakan tag dan opsi gambar.

container:
  image: string # Required. Container image tag.
  endpoint: string # ID of the service endpoint connecting to a private container registry.
  env: # Variables to map into the container's environment.
    string: string # Name/value pairs
  options: string # Options to pass into container host.
  ports: [ string ] # Ports to expose on the container.
  volumes: [ string ] # Volumes to mount on the container.

Properti

image String. Wajib diisi.
Tag gambar kontainer.

endpoint String.
ID titik akhir layanan yang terhubung ke registri kontainer privat.

env kamus string.
Variabel untuk dipetakan ke lingkungan kontainer.

options String.
Opsi untuk masuk ke host kontainer.

ports daftar string.
Port untuk diekspos pada kontainer.

volumes daftar string.
Volume yang akan dipasang pada kontainer.

Contoh

Gunakan options untuk mengonfigurasi startup kontainer.

container:
  image: ubuntu:18.04
  options: --hostname container-test --ip 192.168.0.1

steps:
- script: echo hello

Dalam contoh berikut, kontainer ditentukan di bagian sumber daya. Setiap kontainer kemudian dirujuk kemudian, dengan merujuk ke alias yang ditetapkan.

resources:
  containers:
  - container: u14
    image: ubuntu:14.04

  - container: u16
    image: ubuntu:16.04

  - container: u18
    image: ubuntu:18.04

jobs:
- job: RunInContainer
  pool:
    vmImage: 'ubuntu-18.04'

  strategy:
    matrix:
      ubuntu14:
        containerResource: u14
      ubuntu16:
        containerResource: u16
      ubuntu18:
        containerResource: u18

  container: $[ variables['containerResource'] ]

  steps:
  - script: printenv

Lihat juga