Skip to content

Tag: docker

How to pass backtick to Dockerfile CMD?

I have a docker image running java application, its main class is dynamic, in a file called start-class. Traditionally, I started the application like this. Now I want to run these applications in docker containers. This is my Dockerfile. I built the image and run the containers. The command actually executed…

`sudo` with command substitution

I’m working with a remote machine that requires sudo for most docker commands. I often have to perform multiple repetitive commands to stop docker containers, etc: sudo docker stop <container_name>. Normally, I’d use docker stop $(docker ps -q) to stop all the results of docker ps -q, but si…

How to run a dockerfile?

Found a dockerfile that want to create image and run: https://gist.github.com/matsuu/d5b4e83b3d591441f01b7be2ede774e2 Stored it in a new folder as centos-redhat-8-beta.dockerfile on my computer and tried: What is exact command that need to run? Answer Dockerfile is not an extension, per default the file shoul…

Using $() in docker commands doesn’t seem to work

I want to stop all running docker containers with the command sudo docker stop $(docker ps -a -q). But when I run it, docker outputs Just running docker ps -a -q outputs the Docker IDs, but when I combine it with a Docker command, it doesn’t work. Thank you. Answer I didn’t realize that the sudo i…

ls sort order inside container

Running ls -d to list directories, print directories in different order if trailing / is present in file name. Why is that? What sorting rules apply? and why does this happen only with docker? With trailing / Without trailing / Answer I found out I get the same behavior using sort command But the sorting orde…

Bash get docker image ID automatically

I’m trying to run a few docker commands in my linux machine: But I would like to make a runme.sh and execute all in one run. The problem is that ImageID bf46cff9b182 is dynamiccally changing everytime. So I need to somehow pipe it from the output of the load command, which is in fact possible. The outpu…