I accidentally deleted the wrong repository from Harbor. I read it's now "soft deleted". I wonder if there's a way to bring it back.
Related
In git, there's git rebase to take some commits and copy them on another branch. This is a relatively light operation because the blob nodes underneath aren't duplicated, only the commit node on top is changed. Is there such a thing for docker layers? Can I docker rebase ... a layer onto another image?
Imagine I have a layer that adds a bunch of files. (In this example we can assume it's always additive -- no changing files, no deleting files, only creating new ones where I'm confident nothing in the path existed previously.) Imagine this layer is big and bulky.
Now I invalidate an earlier layer because I wanted to change an environment variable or change a line in a file on a lower-layer. Of course when I next docker build ... it rebuilds from there on, so my new layer is rebuilt too. Except the layer in question doesn't really change -- the hash changes, but the content doesn't. I really don't want to push this layer to my docker repository and pull it to my production runtime. After all, the previous version had all this content.
So can I docker rebase layer abc123 from image mything:v.old onto mynewbase:v.next then tag it as mything:v.next?
I'm using WebSphere Liberty inside. As WebSphere Liberty requires frequent xml editing, which is impossible with Dockerfile commands. I have to docker-commit the container from time to time, for others to make use of my images.
The command is like:
docker commit -m "updated sa1" -a "Song" $id company/wlp:v0.1
Colleges are doing similar things to the image, they continue to docker commit the container several times every day.
One day we're going to deploy the image on production.
Q1: Is the practice of frequent docker-committing advised?
Q2: Does it leave any potential problem behind?
Q3: Does it create an extra layer? I read the docker-commit document, which didn't mention if it creates another layer, I assume it means no.
I wouldn't use docker commit,
It seems like a really good idea but you can't reproduce the image at will like you can with a Dockerfile and you can't change the base image once this is done either, so makes it very hard to commit say for example a security patch to the underlying os base image.
If you go the full Dockerfile approach you can re-run docker build and you'll get the same image again. And you are able to change the base image.
So my rule of thumb is if you are creating a temporary tool and you don't care about reuse or reproducing the image at will then commit is convenient to use.
As I understand Docker every container image has two parts this is a group of read-only layers making up the bulk of the image and then a small layer which is writeable where any changes are committed.
When you run commit docker goes ahead and creates a new image this is the base image plus changes you made (the image created is a distinct image), it copies up the code to the thin writable layer. So a new read-only layer is not created it merely stores the deltas you make into the thin writeable layer.
Don't just take my word for it, take Redhats advice
For clarity that article in step 5 says:
5) Don’t create images from running containers – In other terms, don’t
use “docker commit” to create an image. This method to create an image
is not reproducible and should be completely avoided. Always use a
Dockerfile or any other S2I (source-to-image) approach that is totally
reproducible, and you can track changes to the Dockerfile if you store
it in a source control repository (git).
I'm trying out nexus oss 3.0.1-01. I have a docker repository setup and I'm able to push and pull images successfully. But I need a way delete images. For docker, deleting a component won't actually delete the actual image layers from the file system because it maybe referred to by other components. So, what is the proper way to handle it?
I even deleted every single components and then ran a scheduled task to compact blob store. But that didn't seem to do much in terms of free up storage space.
My understanding is that there isn't a feature in nexus3 at the moment. If there is, could you please point me to some documentation on it? Otherwise, how is everyone else managing their storage space for docker repository?
We had a user contribute this recently:
https://gist.github.com/lukewpatterson/bf9d19410094ea8bced1d4bb0523b67f
You can read about usage here: https://issues.sonatype.org/browse/NEXUS-9293
As well, a supported feature for this will be coming soon from Sonatype.
This is something that needs to be provided at the Docker Registry level. Currently it appears to be broken on v3.1
Did you try to go to assets and delete the layers? If that did not remove the files from the blob store, along with compact blob store, then it is a Nexus problem.
Make sure to tack this issues and confirm that this is the desired behavior for 3.2
See issues
https://issues.sonatype.org/browse/NEXUS-9497
https://issues.sonatype.org/browse/NEXUS-9293
In Nexus 3.14 you go to WebUI -> Tasks -> Create -> Docker - Delete unused manifests and images
Then another job Admin - Compact blob store to actually rm the files from the Nexus directory.
Before that you need to delete the Nexus components (using the cleanup policy+job), as original poster did.
I committed and pushed some code that did not work, which I thought would be a good opportunity to learn how to rollback to a previous commit/pull.
I used reset master to this commit which seemed to work but then I noticed the non-working commit was still there and it said I was 1 behind the most up-to date commit (the commit containing the code that did not work).
I then did something that may have been completely stupid, I used the remove button for the commit I was behind (the earlier code I did not want). After this, the commit is still there but now my uncommitted changes list is just showing a deletion of a file from the commit I wanted to lose.
It seems I've lost all my unstaged files I have been working on all day. How can I get these back and lose the useless commit that I pushed earlier?
Thank you for your time and input.
First things first, I'd recommend reading up on git terms and what different operations actually mean: http://git-scm.com/book/en/v2.
A good surface cheat sheet can be found at http://www.ndpsoftware.com/git-cheatsheet.html Now to get to what you are dealing with.
Remove doesn't remove things from git, in fact, it does exactly what the rm command does on the command line in unix. It removes them from your file system. If you rm files that you hadn't staged, they are just plain gone.
Unfortunately, I can't help you with getting back files you deleted. Look into your OS's recovery tools if you can, but don't hold your breath unless you have a delete cache of some sort (recycle bin on windows).
Revert allows you to make an inverse commit that puts everything back as if you had never made the original commit, but leaves the original in history so you can always see what happened. Despite what people tend to expect, this doesn't eliminate the commit, but actually creates a new one. This is the best option if you are going to be touching stuff that's already been pushed.
Reset changes one of the various states in your git process to allow you to change what you are doing. A soft reset changes just the HEAD pointer that you are pointing at. The command git reset --soft will change your HEAD pointer to whatever commit you provide it (by default HEAD accomplishing nothing). The command git reset will change your HEAD and your staging area to match a given commit (by default HEAD so it just unstages everything). The command git reset --hard will reset HEAD, staging area (aka index) and working directory to match a given commit (again, by default HEAD so you go back to a completely clean environment as if you hadn't done anything since last commit).
If you want to remove a commit completely, that is called resetting the head. Technically the commit itself never goes away, but you can make it so it's unreachable through normal means, and effectively take it out of project history. A word of caution: this should NEVER be done on pushed commits with downstream users. The big question is often, how much do you hate your downstream as the only safe option for them is to re-clone blowing away all of their own work after you do this.
The process would be to git reset --hard HEAD taking your entire environment to the state of the last commit. Then you want to reset --soft HEAD^ which changes the HEAD (what commit you're working off of) to one previous. This leaves you in the state just before you hit commit, with all of your staged changes still staged. At this point, you can discard your changes with git reset --hard HEAD, you can unstage everything with git reset HEAD And finally you can build another commit and move forward.
For a more indepth look at changing history, and why it's basically not allowed after it's been pushed you can look here: http://justinhileman.info/article/changing-history/ there is even a very nice flowchart with command references at the end of the article.
I am considering using Docker for a project, but I have one question I have not been able to find an answer to in the docs or anywhere else: is it possible to commit only a subset of the changes I make to an image?
Let's say I start a container, make a bunch of changes to the filesystem, get my thing working well and then want to commit them to a new base image. However, I only want a small subset of the changes that were actually made (maybe some of them were to log files, or other things that are unimportant). Does docker commit allow to specify that I only want changes, say, under some part of the filesystem to be committed?
You would just first remove the unnessecary files. To my knowledge, partial commits are not supported.
If you want to do this, using docker diff is really handy. You can easily see what the file system changes are that way. You can even run that against a running container.