api.go 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692
  1. /*
  2. Copyright 2020 Docker Compose CLI authors
  3. Licensed under the Apache License, Version 2.0 (the "License");
  4. you may not use this file except in compliance with the License.
  5. You may obtain a copy of the License at
  6. http://www.apache.org/licenses/LICENSE-2.0
  7. Unless required by applicable law or agreed to in writing, software
  8. distributed under the License is distributed on an "AS IS" BASIS,
  9. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. See the License for the specific language governing permissions and
  11. limitations under the License.
  12. */
  13. package api
  14. import (
  15. "context"
  16. "fmt"
  17. "strings"
  18. "time"
  19. "github.com/compose-spec/compose-go/v2/types"
  20. "github.com/docker/cli/opts"
  21. "github.com/docker/compose/v2/pkg/utils"
  22. )
  23. // Service manages a compose project
  24. type Service interface {
  25. // Build executes the equivalent to a `compose build`
  26. Build(ctx context.Context, project *types.Project, options BuildOptions) error
  27. // Push executes the equivalent to a `compose push`
  28. Push(ctx context.Context, project *types.Project, options PushOptions) error
  29. // Pull executes the equivalent of a `compose pull`
  30. Pull(ctx context.Context, project *types.Project, options PullOptions) error
  31. // Create executes the equivalent to a `compose create`
  32. Create(ctx context.Context, project *types.Project, options CreateOptions) error
  33. // Start executes the equivalent to a `compose start`
  34. Start(ctx context.Context, projectName string, options StartOptions) error
  35. // Restart restarts containers
  36. Restart(ctx context.Context, projectName string, options RestartOptions) error
  37. // Stop executes the equivalent to a `compose stop`
  38. Stop(ctx context.Context, projectName string, options StopOptions) error
  39. // Up executes the equivalent to a `compose up`
  40. Up(ctx context.Context, project *types.Project, options UpOptions) error
  41. // Down executes the equivalent to a `compose down`
  42. Down(ctx context.Context, projectName string, options DownOptions) error
  43. // Logs executes the equivalent to a `compose logs`
  44. Logs(ctx context.Context, projectName string, consumer LogConsumer, options LogOptions) error
  45. // Ps executes the equivalent to a `compose ps`
  46. Ps(ctx context.Context, projectName string, options PsOptions) ([]ContainerSummary, error)
  47. // List executes the equivalent to a `docker stack ls`
  48. List(ctx context.Context, options ListOptions) ([]Stack, error)
  49. // Kill executes the equivalent to a `compose kill`
  50. Kill(ctx context.Context, projectName string, options KillOptions) error
  51. // RunOneOffContainer creates a service oneoff container and starts its dependencies
  52. RunOneOffContainer(ctx context.Context, project *types.Project, opts RunOptions) (int, error)
  53. // Remove executes the equivalent to a `compose rm`
  54. Remove(ctx context.Context, projectName string, options RemoveOptions) error
  55. // Exec executes a command in a running service container
  56. Exec(ctx context.Context, projectName string, options RunOptions) (int, error)
  57. // Attach STDIN,STDOUT,STDERR to a running service container
  58. Attach(ctx context.Context, projectName string, options AttachOptions) error
  59. // Copy copies a file/folder between a service container and the local filesystem
  60. Copy(ctx context.Context, projectName string, options CopyOptions) error
  61. // Pause executes the equivalent to a `compose pause`
  62. Pause(ctx context.Context, projectName string, options PauseOptions) error
  63. // UnPause executes the equivalent to a `compose unpause`
  64. UnPause(ctx context.Context, projectName string, options PauseOptions) error
  65. // Top executes the equivalent to a `compose top`
  66. Top(ctx context.Context, projectName string, services []string) ([]ContainerProcSummary, error)
  67. // Events executes the equivalent to a `compose events`
  68. Events(ctx context.Context, projectName string, options EventsOptions) error
  69. // Port executes the equivalent to a `compose port`
  70. Port(ctx context.Context, projectName string, service string, port uint16, options PortOptions) (string, int, error)
  71. // Publish executes the equivalent to a `compose publish`
  72. Publish(ctx context.Context, project *types.Project, repository string, options PublishOptions) error
  73. // Images executes the equivalent of a `compose images`
  74. Images(ctx context.Context, projectName string, options ImagesOptions) ([]ImageSummary, error)
  75. // MaxConcurrency defines upper limit for concurrent operations against engine API
  76. MaxConcurrency(parallel int)
  77. // DryRunMode defines if dry run applies to the command
  78. DryRunMode(ctx context.Context, dryRun bool) (context.Context, error)
  79. // Watch services' development context and sync/notify/rebuild/restart on changes
  80. Watch(ctx context.Context, project *types.Project, services []string, options WatchOptions) error
  81. // Viz generates a graphviz graph of the project services
  82. Viz(ctx context.Context, project *types.Project, options VizOptions) (string, error)
  83. // Wait blocks until at least one of the services' container exits
  84. Wait(ctx context.Context, projectName string, options WaitOptions) (int64, error)
  85. // Scale manages numbers of container instances running per service
  86. Scale(ctx context.Context, project *types.Project, options ScaleOptions) error
  87. // Export a service container's filesystem as a tar archive
  88. Export(ctx context.Context, projectName string, options ExportOptions) error
  89. // Create a new image from a service container's changes
  90. Commit(ctx context.Context, projectName string, options CommitOptions) error
  91. // Generate generates a Compose Project from existing containers
  92. Generate(ctx context.Context, options GenerateOptions) (*types.Project, error)
  93. }
  94. type ScaleOptions struct {
  95. Services []string
  96. }
  97. type WaitOptions struct {
  98. // Services passed in the command line to be waited
  99. Services []string
  100. // Executes a down when a container exits
  101. DownProjectOnContainerExit bool
  102. }
  103. type VizOptions struct {
  104. // IncludeNetworks if true, network names a container is attached to should appear in the graph node
  105. IncludeNetworks bool
  106. // IncludePorts if true, ports a container exposes should appear in the graph node
  107. IncludePorts bool
  108. // IncludeImageName if true, name of the image used to create a container should appear in the graph node
  109. IncludeImageName bool
  110. // Indentation string to be used to indent graphviz code, e.g. "\t", " "
  111. Indentation string
  112. }
  113. // WatchLogger is a reserved name to log watch events
  114. const WatchLogger = "#watch"
  115. // WatchOptions group options of the Watch API
  116. type WatchOptions struct {
  117. Build *BuildOptions
  118. LogTo LogConsumer
  119. Prune bool
  120. }
  121. // BuildOptions group options of the Build API
  122. type BuildOptions struct {
  123. // Pull always attempt to pull a newer version of the image
  124. Pull bool
  125. // Push pushes service images
  126. Push bool
  127. // Progress set type of progress output ("auto", "plain", "tty")
  128. Progress string
  129. // Args set build-time args
  130. Args types.MappingWithEquals
  131. // NoCache disables cache use
  132. NoCache bool
  133. // Quiet make the build process not output to the console
  134. Quiet bool
  135. // Services passed in the command line to be built
  136. Services []string
  137. // Deps also build selected services dependencies
  138. Deps bool
  139. // Ssh authentications passed in the command line
  140. SSHs []types.SSHKey
  141. // Memory limit for the build container
  142. Memory int64
  143. // Builder name passed in the command line
  144. Builder string
  145. // Print don't actually run builder but print equivalent build config
  146. Print bool
  147. // Check let builder validate build configuration
  148. Check bool
  149. // Provenance
  150. Provenance *string
  151. }
  152. // Apply mutates project according to build options
  153. func (o BuildOptions) Apply(project *types.Project) error {
  154. platform := project.Environment["DOCKER_DEFAULT_PLATFORM"]
  155. for name, service := range project.Services {
  156. if service.Provider == nil && service.Image == "" && service.Build == nil {
  157. return fmt.Errorf("invalid service %q. Must specify either image or build", name)
  158. }
  159. if service.Build == nil {
  160. continue
  161. }
  162. if platform != "" {
  163. if len(service.Build.Platforms) > 0 && !utils.StringContains(service.Build.Platforms, platform) {
  164. return fmt.Errorf("service %q build.platforms does not support value set by DOCKER_DEFAULT_PLATFORM: %s", name, platform)
  165. }
  166. service.Platform = platform
  167. }
  168. if service.Platform != "" {
  169. if len(service.Build.Platforms) > 0 && !utils.StringContains(service.Build.Platforms, service.Platform) {
  170. return fmt.Errorf("service %q build configuration does not support platform: %s", name, service.Platform)
  171. }
  172. }
  173. service.Build.Pull = service.Build.Pull || o.Pull
  174. service.Build.NoCache = service.Build.NoCache || o.NoCache
  175. project.Services[name] = service
  176. }
  177. return nil
  178. }
  179. // CreateOptions group options of the Create API
  180. type CreateOptions struct {
  181. Build *BuildOptions
  182. // Services defines the services user interacts with
  183. Services []string
  184. // Remove legacy containers for services that are not defined in the project
  185. RemoveOrphans bool
  186. // Ignore legacy containers for services that are not defined in the project
  187. IgnoreOrphans bool
  188. // Recreate define the strategy to apply on existing containers
  189. Recreate string
  190. // RecreateDependencies define the strategy to apply on dependencies services
  191. RecreateDependencies string
  192. // Inherit reuse anonymous volumes from previous container
  193. Inherit bool
  194. // Timeout set delay to wait for container to gracefully stop before sending SIGKILL
  195. Timeout *time.Duration
  196. // QuietPull makes the pulling process quiet
  197. QuietPull bool
  198. // AssumeYes assume "yes" as answer to all prompts and run non-interactively
  199. AssumeYes bool
  200. }
  201. // StartOptions group options of the Start API
  202. type StartOptions struct {
  203. // Project is the compose project used to define this app. Might be nil if user ran command just with project name
  204. Project *types.Project
  205. // Attach to container and forward logs if not nil
  206. Attach LogConsumer
  207. // AttachTo set the services to attach to
  208. AttachTo []string
  209. // OnExit defines behavior when a container stops
  210. OnExit Cascade
  211. // ExitCodeFrom return exit code from specified service
  212. ExitCodeFrom string
  213. // Wait won't return until containers reached the running|healthy state
  214. Wait bool
  215. WaitTimeout time.Duration
  216. // Services passed in the command line to be started
  217. Services []string
  218. Watch bool
  219. NavigationMenu bool
  220. }
  221. type Cascade int
  222. const (
  223. CascadeIgnore Cascade = iota
  224. CascadeStop Cascade = iota
  225. CascadeFail Cascade = iota
  226. )
  227. // RestartOptions group options of the Restart API
  228. type RestartOptions struct {
  229. // Project is the compose project used to define this app. Might be nil if user ran command just with project name
  230. Project *types.Project
  231. // Timeout override container restart timeout
  232. Timeout *time.Duration
  233. // Services passed in the command line to be restarted
  234. Services []string
  235. // NoDeps ignores services dependencies
  236. NoDeps bool
  237. }
  238. // StopOptions group options of the Stop API
  239. type StopOptions struct {
  240. // Project is the compose project used to define this app. Might be nil if user ran command just with project name
  241. Project *types.Project
  242. // Timeout override container stop timeout
  243. Timeout *time.Duration
  244. // Services passed in the command line to be stopped
  245. Services []string
  246. }
  247. // UpOptions group options of the Up API
  248. type UpOptions struct {
  249. Create CreateOptions
  250. Start StartOptions
  251. }
  252. // DownOptions group options of the Down API
  253. type DownOptions struct {
  254. // RemoveOrphans will cleanup containers that are not declared on the compose model but own the same labels
  255. RemoveOrphans bool
  256. // Project is the compose project used to define this app. Might be nil if user ran `down` just with project name
  257. Project *types.Project
  258. // Timeout override container stop timeout
  259. Timeout *time.Duration
  260. // Images remove image used by services. 'all': Remove all images. 'local': Remove only images that don't have a tag
  261. Images string
  262. // Volumes remove volumes, both declared in the `volumes` section and anonymous ones
  263. Volumes bool
  264. // Services passed in the command line to be stopped
  265. Services []string
  266. }
  267. // ConfigOptions group options of the Config API
  268. type ConfigOptions struct {
  269. // Format define the output format used to dump converted application model (json|yaml)
  270. Format string
  271. // Output defines the path to save the application model
  272. Output string
  273. // Resolve image reference to digests
  274. ResolveImageDigests bool
  275. }
  276. // PushOptions group options of the Push API
  277. type PushOptions struct {
  278. Quiet bool
  279. IgnoreFailures bool
  280. ImageMandatory bool
  281. }
  282. // PullOptions group options of the Pull API
  283. type PullOptions struct {
  284. Quiet bool
  285. IgnoreFailures bool
  286. IgnoreBuildable bool
  287. }
  288. // ImagesOptions group options of the Images API
  289. type ImagesOptions struct {
  290. Services []string
  291. }
  292. // KillOptions group options of the Kill API
  293. type KillOptions struct {
  294. // RemoveOrphans will cleanup containers that are not declared on the compose model but own the same labels
  295. RemoveOrphans bool
  296. // Project is the compose project used to define this app. Might be nil if user ran command just with project name
  297. Project *types.Project
  298. // Services passed in the command line to be killed
  299. Services []string
  300. // Signal to send to containers
  301. Signal string
  302. // All can be set to true to try to kill all found containers, independently of their state
  303. All bool
  304. }
  305. // RemoveOptions group options of the Remove API
  306. type RemoveOptions struct {
  307. // Project is the compose project used to define this app. Might be nil if user ran command just with project name
  308. Project *types.Project
  309. // Stop option passed in the command line
  310. Stop bool
  311. // Volumes remove anonymous volumes
  312. Volumes bool
  313. // Force don't ask to confirm removal
  314. Force bool
  315. // Services passed in the command line to be removed
  316. Services []string
  317. }
  318. // RunOptions group options of the Run API
  319. type RunOptions struct {
  320. Build *BuildOptions
  321. // Project is the compose project used to define this app. Might be nil if user ran command just with project name
  322. Project *types.Project
  323. Name string
  324. Service string
  325. Command []string
  326. Entrypoint []string
  327. Detach bool
  328. AutoRemove bool
  329. Tty bool
  330. Interactive bool
  331. WorkingDir string
  332. User string
  333. Environment []string
  334. CapAdd []string
  335. CapDrop []string
  336. Labels types.Labels
  337. Privileged bool
  338. UseNetworkAliases bool
  339. NoDeps bool
  340. // QuietPull makes the pulling process quiet
  341. QuietPull bool
  342. // used by exec
  343. Index int
  344. }
  345. // AttachOptions group options of the Attach API
  346. type AttachOptions struct {
  347. Project *types.Project
  348. Service string
  349. Index int
  350. DetachKeys string
  351. NoStdin bool
  352. Proxy bool
  353. }
  354. // EventsOptions group options of the Events API
  355. type EventsOptions struct {
  356. Services []string
  357. Consumer func(event Event) error
  358. }
  359. // Event is a container runtime event served by Events API
  360. type Event struct {
  361. Timestamp time.Time
  362. Service string
  363. Container string
  364. Status string
  365. Attributes map[string]string
  366. }
  367. // PortOptions group options of the Port API
  368. type PortOptions struct {
  369. Protocol string
  370. Index int
  371. }
  372. // OCIVersion controls manifest generation to ensure compatibility
  373. // with different registries.
  374. //
  375. // Currently, this is not exposed as an option to the user – Compose uses
  376. // OCI 1.0 mode automatically for ECR registries based on domain and OCI 1.1
  377. // for all other registries.
  378. //
  379. // There are likely other popular registries that do not support the OCI 1.1
  380. // format, so it might make sense to expose this as a CLI flag or see if
  381. // there's a way to generically probe the registry for support level.
  382. type OCIVersion string
  383. const (
  384. OCIVersion1_0 OCIVersion = "1.0"
  385. OCIVersion1_1 OCIVersion = "1.1"
  386. )
  387. // PublishOptions group options of the Publish API
  388. type PublishOptions struct {
  389. ResolveImageDigests bool
  390. WithEnvironment bool
  391. AssumeYes bool
  392. OCIVersion OCIVersion
  393. }
  394. func (e Event) String() string {
  395. t := e.Timestamp.Format("2006-01-02 15:04:05.000000")
  396. var attr []string
  397. for k, v := range e.Attributes {
  398. attr = append(attr, fmt.Sprintf("%s=%s", k, v))
  399. }
  400. return fmt.Sprintf("%s container %s %s (%s)\n", t, e.Status, e.Container, strings.Join(attr, ", "))
  401. }
  402. // ListOptions group options of the ls API
  403. type ListOptions struct {
  404. All bool
  405. }
  406. // PsOptions group options of the Ps API
  407. type PsOptions struct {
  408. Project *types.Project
  409. All bool
  410. Services []string
  411. }
  412. // CopyOptions group options of the cp API
  413. type CopyOptions struct {
  414. Source string
  415. Destination string
  416. All bool
  417. Index int
  418. FollowLink bool
  419. CopyUIDGID bool
  420. }
  421. // PortPublisher hold status about published port
  422. type PortPublisher struct {
  423. URL string
  424. TargetPort int
  425. PublishedPort int
  426. Protocol string
  427. }
  428. // ContainerSummary hold high-level description of a container
  429. type ContainerSummary struct {
  430. ID string
  431. Name string
  432. Names []string
  433. Image string
  434. Command string
  435. Project string
  436. Service string
  437. Created int64
  438. State string
  439. Status string
  440. Health string
  441. ExitCode int
  442. Publishers PortPublishers
  443. Labels map[string]string
  444. SizeRw int64 `json:",omitempty"`
  445. SizeRootFs int64 `json:",omitempty"`
  446. Mounts []string
  447. Networks []string
  448. LocalVolumes int
  449. }
  450. // PortPublishers is a slice of PortPublisher
  451. type PortPublishers []PortPublisher
  452. // Len implements sort.Interface
  453. func (p PortPublishers) Len() int {
  454. return len(p)
  455. }
  456. // Less implements sort.Interface
  457. func (p PortPublishers) Less(i, j int) bool {
  458. left := p[i]
  459. right := p[j]
  460. if left.URL != right.URL {
  461. return left.URL < right.URL
  462. }
  463. if left.TargetPort != right.TargetPort {
  464. return left.TargetPort < right.TargetPort
  465. }
  466. if left.PublishedPort != right.PublishedPort {
  467. return left.PublishedPort < right.PublishedPort
  468. }
  469. return left.Protocol < right.Protocol
  470. }
  471. // Swap implements sort.Interface
  472. func (p PortPublishers) Swap(i, j int) {
  473. p[i], p[j] = p[j], p[i]
  474. }
  475. // ContainerProcSummary holds container processes top data
  476. type ContainerProcSummary struct {
  477. ID string
  478. Name string
  479. Processes [][]string
  480. Titles []string
  481. Service string
  482. Replica string
  483. }
  484. // ImageSummary holds container image description
  485. type ImageSummary struct {
  486. ID string
  487. ContainerName string
  488. Repository string
  489. Tag string
  490. Size int64
  491. LastTagTime time.Time
  492. }
  493. // ServiceStatus hold status about a service
  494. type ServiceStatus struct {
  495. ID string
  496. Name string
  497. Replicas int
  498. Desired int
  499. Ports []string
  500. Publishers []PortPublisher
  501. }
  502. // LogOptions defines optional parameters for the `Log` API
  503. type LogOptions struct {
  504. Project *types.Project
  505. Index int
  506. Services []string
  507. Tail string
  508. Since string
  509. Until string
  510. Follow bool
  511. Timestamps bool
  512. }
  513. // PauseOptions group options of the Pause API
  514. type PauseOptions struct {
  515. // Services passed in the command line to be started
  516. Services []string
  517. // Project is the compose project used to define this app. Might be nil if user ran command just with project name
  518. Project *types.Project
  519. }
  520. // ExportOptions group options of the Export API
  521. type ExportOptions struct {
  522. Service string
  523. Index int
  524. Output string
  525. }
  526. // CommitOptions group options of the Commit API
  527. type CommitOptions struct {
  528. Service string
  529. Reference string
  530. Pause bool
  531. Comment string
  532. Author string
  533. Changes opts.ListOpts
  534. Index int
  535. }
  536. type GenerateOptions struct {
  537. // ProjectName to set in the Compose file
  538. ProjectName string
  539. // Containers passed in the command line to be used as reference for service definition
  540. Containers []string
  541. }
  542. const (
  543. // STARTING indicates that stack is being deployed
  544. STARTING string = "Starting"
  545. // RUNNING indicates that stack is deployed and services are running
  546. RUNNING string = "Running"
  547. // UPDATING indicates that some stack resources are being recreated
  548. UPDATING string = "Updating"
  549. // REMOVING indicates that stack is being deleted
  550. REMOVING string = "Removing"
  551. // UNKNOWN indicates unknown stack state
  552. UNKNOWN string = "Unknown"
  553. // FAILED indicates that stack deployment failed
  554. FAILED string = "Failed"
  555. )
  556. const (
  557. // RecreateDiverged to recreate services which configuration diverges from compose model
  558. RecreateDiverged = "diverged"
  559. // RecreateForce to force service container being recreated
  560. RecreateForce = "force"
  561. // RecreateNever to never recreate existing service containers
  562. RecreateNever = "never"
  563. )
  564. // Stack holds the name and state of a compose application/stack
  565. type Stack struct {
  566. ID string
  567. Name string
  568. Status string
  569. ConfigFiles string
  570. Reason string
  571. }
  572. // LogConsumer is a callback to process log messages from services
  573. type LogConsumer interface {
  574. Log(containerName, message string)
  575. Err(containerName, message string)
  576. Status(container, msg string)
  577. Register(container string)
  578. }
  579. // ContainerEventListener is a callback to process ContainerEvent from services
  580. type ContainerEventListener func(event ContainerEvent)
  581. // ContainerEvent notify an event has been collected on source container implementing Service
  582. type ContainerEvent struct {
  583. Type int
  584. // Container is the name of the container _without the project prefix_.
  585. //
  586. // This is only suitable for display purposes within Compose, as it's
  587. // not guaranteed to be unique across services.
  588. Container string
  589. ID string
  590. Service string
  591. Line string
  592. // ContainerEventExit only
  593. ExitCode int
  594. Restarting bool
  595. }
  596. const (
  597. // ContainerEventLog is a ContainerEvent of type log on stdout. Line is set
  598. ContainerEventLog = iota
  599. // ContainerEventErr is a ContainerEvent of type log on stderr. Line is set
  600. ContainerEventErr
  601. // ContainerEventAttach is a ContainerEvent of type attach. First event sent about a container
  602. ContainerEventAttach
  603. // ContainerEventStopped is a ContainerEvent of type stopped.
  604. ContainerEventStopped
  605. // ContainerEventRecreated let consumer know container stopped but his being replaced
  606. ContainerEventRecreated
  607. // ContainerEventExit is a ContainerEvent of type exit. ExitCode is set
  608. ContainerEventExit
  609. // UserCancel user cancelled compose up, we are stopping containers
  610. UserCancel
  611. // HookEventLog is a ContainerEvent of type log on stdout by service hook
  612. HookEventLog
  613. )
  614. // Separator is used for naming components
  615. var Separator = "-"
  616. // GetImageNameOrDefault computes the default image name for a service, used to tag built images
  617. func GetImageNameOrDefault(service types.ServiceConfig, projectName string) string {
  618. imageName := service.Image
  619. if imageName == "" {
  620. imageName = projectName + Separator + service.Name
  621. }
  622. return imageName
  623. }