Home > Software engineering >  How to combine docker creation and putting it in DEV Azure Container Registry?
How to combine docker creation and putting it in DEV Azure Container Registry?

Time:12-16

Here is my scenario: I create a docker image from an SQL dump with the following commands, executed from command prompt:

docker pull mariadb:10.4.26
docker run --name test_smdb -e MYSQL_ROOT_PASSWORD=<some_password> -p 3306:3306 -d mariadb:10.4.26
docker exec -it test_smdb mariadb --user root -p<some_password>
MariaDB [(none)]> CREATE DATABASE smdb_dev;
docker exec -i test_smdb mariadb -uroot -pVienna0nly! smdb_dev --force < C:\smdb-dev.sql

But my task now is create a pipeline, that creates this docker image and puts it into the Azure Container Registry

I found this link - Build and push Docker images to Azure Container Registry: https://learn.microsoft.com/en-us/azure/devops/pipelines/ecosystems/containers/acr-template?view=azure-devops

And i see that the result should be a yaml file like this:

- stage: Build
  displayName: Build and push stage
  jobs:  
  - job: Build
    displayName: Build job
    pool:
      vmImage: $(vmImageName)
    steps:
    - task: Docker@2
      displayName: Build and push an image to container registry
      inputs:
        command: buildAndPush
        repository: $(imageRepository)
        dockerfile: $(dockerfilePath)
        containerRegistry: $(dockerRegistryServiceConnection)
        tags: |
          $(tag)

But can someone show me how to combine the two things - the docker image creation and the putting it into the Azure Container Registry?

CodePudding user response:

You would need to make a dockerfile and put this in the repository. The commands you specified at the top of your question should be your input It could look something like this (just threw something together. probably wont work as is):

# syntax=docker/dockerfile:1
FROM mariadb:10.4.26
WORKDIR /app
COPY . .
run --name test_smdb -e MYSQL_ROOT_PASSWORD=<some_password> -p 3306:3306 -d mariadb:10.4.26
run MariaDB [(none)]> CREATE DATABASE smdb_dev;
EXPOSE {mariadb port #}
  • Related