Docker image name - docker-image

How to create a image/tag name for the existing image? I have following images currently:
I would like to create repository name and tag name of the existing image.

you can use docker tag for this
docker tag cdcbb3706c83 {your tag name}
https://docs.docker.com/engine/reference/commandline/tag/

I have used following command to create repository and tag name:
docker tag cdcbb3706c83 aspcore:dev
Thanks.

ITNOA
As you can see in docker tag manual you can use
docker tag SOURCE_IMAGE[:TAG] TARGET_IMAGE[:TAG]
example
docker tag 0e5574283393 fedora/httpd:version1.0

Related

Where is locate pidfile | docker for windows | docker.pid

I would like to have docker inside docker for use CI-agent. But for it I need to share docker.pid file inside docker container and I can't find that file in this path C:\ProgramData\docker.pid and even I try to add this in docker daemon config:
{
...
"pidfile": "C:\\docker.pid",
...
}
And after a restart, that file didn't appear.
Could you please help me?
Also tried different variant in config file like "C:\docker.pid", "C:/docker.pid". The same behavior.
The docker logs is clean about creating or removing docker.pid file.
Software info
Windows Version: 10 1809 build 17763
Docker for Windows Version: 2.0.0.2 31259
Expected behavior
Create pid file in path C:\docker.pid
Actual behavior
The file is absent
Also created an issue in github
https://github.com/docker/for-win/issues/3741
I found a way to run Docker inside docker.
These two topics help me:
https://forums.docker.com/t/solved-using-docker-inside-another-container/12222/3
Bind to docker socket on Windows
I needed docker.sock file and it locate //var/run/docker.sock so
-v //var/run/docker.sock:/var/run/docker.sock
resolve my problem.

Is there a way to change selenium/node-chrome image chromedriver.exe version?

I am running Selenium-hub and Selenium node chrome on Docker containers and I need to change the version of the chromedriver wihtout affecting the image version.
That is, imagine I am using selenium-hub: image: selenium/hub:3.3.1-cesium and selenium-chrome: image: selenium/node-chrome:3.3.1-cesium but I want to update the chromedriver version to 2.41, without affecting the docker image version.
Is there a way to do this?
Thanks in advance.
I can say that there is no way to do this with selenium/node-chrome image.
Why ? because this image belongs to selenium. You cannot change the image that you are not the owner.
But you can create your own image based on selenium/node-chrome. Simply just run a selenium/node-chrome container with name node_chrome_container, you can change chromedriver to the version you want inside that container and then commit it to your own image.
docker commit -m "Added custom image" node_chrome_container DOCKER_HUB_USER/custom-node-chrome:latest
I will be on your local PC. You should also push that image to docker hub under your repository.
docker push DOCKER_HUB_USER/custom-node-chrome
link reference here: https://www.techrepublic.com/article/how-to-create-a-docker-image-and-push-it-to-docker-hub/

Variable expansion in image and repo name

Am using drone docker plugin to build and publish docker images, while building the docker image, i want refer some of the env variables exposed by Drone in drone docker plugin repo and tags parameters.
What is needed
repo = first three characters of DRONE_COMMIT_BRANCH variable value - like ${DRONE_COMMIT_BRANCH:0:3}, not working
tags = first seven characters of DRONE_COMMIT_SHA variable value, like ${DRONE_COMMIT_SHA:0:7}, working
image = should be according to above repo and tags like,
Eg:- image: registry/repo:tag
image: registry/${DRONE_COMMIT_BRANCH:0:3}:${DRONE_COMMIT_SHA:0:7}
Concerns
I can use any env variable exposed by Drone for such purpose, or only
specific is only can be used?
drone docker plugin repo parameter supports env variable
expansion and string manipulation, as supported by tags
parameter?
image parameter support variable expansion and string manipulation?
Drone YAML file
Please suggest me how to achieve this use case?
Thanks in advance.

Declaring variables in docker-compose

I want to let my application know which image version it is running on.
The idea was to pass the Docker image tag into the image as an environment variable. However I don't want to change the version number in both the image line AND in the ENV variable line all the time.
Example:
version: "3"
VERSION=0.2.3
services:
app:
image: myimage:$VERSION
environment:
- APPLICATION_VERSION:$VERSION
Is it possible to declare variables in order to update all values together or is there any other solution available?
You cannot define $VERSION inside the docker-compose.yml.
You have two options for this:
define it in a .env file
send as a command line argument when you run the docker-compose command. e.g. VERSION=0.2.3 docker-compose up -d

Best practice using Dockerfile with docker-compose and vcs

I have a question regarding best practice.
Lets say I have a webfrontend developed in angularjs and a api to get data from. I put those two in separate repositories.
Now I want to dockerize the whole thing. My idea was to put a Dockerfile in each project which specifies their environment. Until now its fine but what when I also have a docker-compose file which starts those two services simultanously? First of in which repo should I put this file and secondly how can I assure, that the images are always uptodate?
You can use a structure like this:
project/
- project/docker-compose.yaml
- project/frontend/ (contains Dockerfile + necessary files)
- project/api/ (contains Dockerfile + necessary files)
In your docker-compose.yaml you can write something like this for each image:
frontend:
build: ./frontend #folder in which Dockerfile of frontend is saved (to build the image)
image: my-frontend:1.0 #give a name to your image
container_name: frontend-container #containername when a container instance of your image is running
To start docker-compose you can run docker-compose up --build. The --build tag will recreate your images when there are changes so you can keep your compose up to date when there are changes in the dockerfile (image).
Docker-compose is 'reading' from up to bottom. So the service you describe first in your docker-compose.yaml will be created first. I would think it's your API because that can probably exist on its own and your frontend needs to connect with it. Sometimes your first service is started too slow, which means the second service is already up but can not find the first service (to connect with) and it crashes. This can be solved by using a wait-for-it.sh script. Your second service will use the script and check when the first service is up. When it's up, it will start its own service.